|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
array length
Might seem a bit basic, but how do you get the length of an array, in order to make the length of it equal to a given variable?
Cheers. Flink. |
|
#2
|
|||
|
|||
|
$#arrayname
|
|
#3
|
|||
|
|||
|
Ummm
Ok, $#Arrayname will give you the length of the array... but it gives it as the literal highest number you have established in it... which isn't very helpful if you have an array with only one entry.
to get the real number of entrys for an array... use scalar(@ARRAYNAME) |
|
#4
|
|||
|
|||
|
$#arrayname gives you the subscript of the last element you have in said array, which really translates to length minus one.
As Flame said, you could use: Code:
$len = scalar(@arrayname); Or you could use simply: Code:
$len = @arrayname; Hope that helps.
__________________
- dsb - ![]() Perl Guy |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > array length |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|