Re: Printing size of array unitializes array?

2007-10-19 Thread Dr.Ruud
Matthew Whipple schreef: > If you're looking for the last element then you could > use $files[$#files] Or $files[-1]. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
I use the scalar keyword on occasion: #!/usr/bin/perl my @arr = qw/adfs adsf 4fd feqw3 f432d/; print "The size of the array is " . scalar (@arr) . "\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
Matthew Whipple wrote: > yitzle wrote: > >> What are you trying to accomplish? >> What is @files? Did you define it somewhere? Or is it a Perl global >> var I don't know of? >> >> >> > The below is speculation since these questions need to be answered. In > addition to what is @files I'

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
m: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle > Sent: October-19-07 11:16 AM > To: Joseph L. Casale > Cc: beginners@perl.org > Subject: Re: Printing size of array unitializes array? > > What are you trying to accomplish? > What is @files? Did you define it som

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
yitzle wrote: > What are you trying to accomplish? > What is @files? Did you define it somewhere? Or is it a Perl global > var I don't know of? > > The below is speculation since these questions need to be answered. In addition to what is @files I'd add what is $Tmp? > On 10/19/07, Joseph L. Ca

Re: Printing size of array unitializes array?

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > open (FILEOUT, "> $OutDir/info") or die $!; > print FILEOUT "text = abc\n"; > my $Tmp = ++$#files; Huh? > print FILEOUT "moretext = $Tmp\n"; > When I add the 3rd line, it initializes the fi

RE: Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
Sorry, it is an array I used above this block of code. jlc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle Sent: October-19-07 11:16 AM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Printing size of array unitializes array? What are you

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
What are you trying to accomplish? What is @files? Did you define it somewhere? Or is it a Perl global var I don't know of? On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > I had the following code: > > open (FILEOUT, "> $OutDir/info") or die $!; > print FILEOUT "text =

Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
I had the following code: open (FILEOUT, "> $OutDir/info") or die $!; print FILEOUT "text = abc\n"; my $Tmp = ++$#files; print FILEOUT "moretext = $Tmp\n"; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that

Re: determining size of array through reference

2004-04-09 Thread Adam
I guess you could always dereference the array then find its size. my(@sample, $ref, @de_ref); # Original array. @sample = ('sample', 'sample'); # Make reference to original array. $ref = [EMAIL PROTECTED]; # De-reference the original array. @de_ref = @$ref; # Get the size from the reference. pri

Re: determining size of array through reference

2004-04-07 Thread R. Joseph Newton
Andrew Gaffney wrote: > david wrote: > > Andrew Gaffney wrote: > > > > > >>I've got an array reference and I'm trying to figure out how many elements > >>are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and > >>probably a few others that I've forgotten. What is the corre

Re: determining size of array through reference

2004-04-07 Thread Rob Dixon
Andrew Gaffney wrote: > > david wrote: > > Andrew Gaffney wrote: > > > > > >>I've got an array reference and I'm trying to figure out how many elements > >>are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and > >>probably a few others that I've forgotten. What is the corr

Re: determining size of array through reference

2004-04-06 Thread Andrew Gaffney
david wrote: Andrew Gaffney wrote: I've got an array reference and I'm trying to figure out how many elements are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and probably a few others that I've forgotten. What is the correct way to do this? you can try @{EXP} or $#{E

Re: determining size of array through reference

2004-04-06 Thread david
Andrew Gaffney wrote: > I've got an array reference and I'm trying to figure out how many elements > are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and > probably a few others that I've forgotten. What is the correct way to do > this? you can try @{EXP} or $#{EXP}+1 w

determining size of array through reference

2004-04-06 Thread Andrew Gaffney
I've got an array reference and I'm trying to figure out how many elements are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and probably a few others that I've forgotten. What is the correct way to do this? -- Andrew Gaffney Network Administrator Skyline Aeronautics, L

RE: Size of Array

2002-02-18 Thread John Edwards
rraysize elements\n"; my $arraysize = @{$array[1]}; print "Second sub array size is $arraysize elements\n"; HTH John -Original Message- From: Agustin Rivera [mailto:[EMAIL PROTECTED]] Sent: 18 February 2002 17:18 To: [EMAIL PROTECTED] Subject: Size of Array Thank-you to everyo

Re: Size of Array

2002-02-18 Thread Frank
On Mon, Feb 18, 2002 at 09:17:50AM -0800, Agustin wrote: > Quick one.. is there a way to evaluate the size of an array? Right now I'm > writing the arrays to a file and then doing an "ls -l" to compare sizes. The > array is of type $array[0][0] and not $array[0] (if anyone has the proper > termin

Size of Array

2002-02-18 Thread Agustin Rivera
Thank-you to everyone who answered my last question. As usually I am very grateful for this group and the people in it. Quick one.. is there a way to evaluate the size of an array? Right now I'm writing the arrays to a file and then doing an "ls -l" to compare sizes. The array is of type $array