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