I'm just learning perl, and i need to find a way to check to see if i'm at the last element in my array... how would i go about this?
mdharrold
3:30 am on Jun 5, 2002 (gmt 0)
scalar(@array) gives you the number of elements in the array. Is that what you were wanted?
Brett_Tabke
6:29 am on Jun 5, 2002 (gmt 0)
you can also do $#array.
$thelength =$#array;
That comes out as array-1 (counting zero).
I know that really breaks from perls standard syntax with the # char, but that's the way they do it.
scotty
10:05 am on Jun 5, 2002 (gmt 0)
> you can also do $#array... <snip>
That's probably coming from the bourn shell "heritage" where you look at the number of arguments using $#... Wait until Perl 6 comes out, and then everything will be different again. :(
Brett_Tabke
10:10 am on Jun 5, 2002 (gmt 0)
you don't always have to use "scalar" you can do just