RE: Getting the length of an array that is a reference...

2001-08-31 Thread Bill Odom
Hamish Whittal said: > > I have a reference to an array $ref_arr > > I want the length of the array. normally just getting the length one > would write something along the lines of: > $length = @#array; # Unless I am mistaken. Close -- you want $#array instead. > > How do I find the length

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Paul Johnson
On Fri, Aug 31, 2001 at 08:02:32PM +0530, [EMAIL PROTECTED] wrote: > You can also use $#{$array} to get the length.. Except that is not the length, unless you've messed with $[, which you haven't, right? perldoc perlvar for more info on $[ - but read the whole entry. -- Paul Johnson - [EMAIL

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Randal L. Schwartz
> "Aravindan" == Aravindan Sundaram <[EMAIL PROTECTED]> writes: Aravindan> You can also use $#{$array} to get the length.. No, that gets the highest index. One short of the length. Aravindan> Aravindan> This electronic mail message is intend

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Brett W. McCoy
On Fri, 31 Aug 2001 [EMAIL PROTECTED] wrote: > You can also use $#{$array} to get the length.. No, that only gives you the index of the last element! You will be off by one if you do it that way. The correct way is to put the array (or array ref) into a scalar context, which gives the length o

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Aravindan . Sundaram
You can also use $#{$array} to get the length.. Hamish Whittal To: perl beginners

Re: Getting the length of an array that is a reference...

2001-08-31 Thread register
You can always do this scalar @$ref_arr but this will give you the number of elements not the last index as $#array would On Fri, Aug 31, 2001 at 01:24:53PM -0200, Hamish Whittal shaped the electrons to read: > Hi, > > I have a reference to an array $ref_arr > > I want the length of th

RE: Getting the length of an array that is a reference...

2001-08-31 Thread Bob Showalter
> -Original Message- > From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] > Sent: Friday, August 31, 2001 8:24 AM > To: Hamish Whittal > Cc: perl beginners > Subject: Re: Getting the length of an array that is a reference... > > > On Fri, 31 Aug 2001, Hamish W

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Brett W. McCoy
On Fri, 31 Aug 2001, Hamish Whittal wrote: > I want the length of the array. normally just getting the length one > would write something along the lines of: > $length = @#array; # Unless I am mistaken. That's the incorrect way to get the length of the array anyway -- you are only getting

Re: Getting the length of an array that is a reference...

2001-08-31 Thread Jos I. Boumans
you'll need to dereference it.. this would work for you: perl -e "$ref=[qw(1 2 3)]; print scalar @$ref" regards, Jos Boumans - Original Message - From: "Hamish Whittal" <[EMAIL PROTECTED]> To: "perl beginners" <[EMAIL PROTECTED]> Sent: Friday, August 31, 2001 5:24 PM Subject: Gettin