you have told i not to increment past 0 but making $num your count. as your print out shows, $num never gets past 1. I am not sure what you want $num to be? do you want it to be a count of chars in the scalar string $url ? if so, try length()
> -----Original Message----- > From: Pam Derks [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, December 17, 2002 9:51 AM > To: [EMAIL PROTECTED] > Subject: problems with scalar(@array) > > > Howdy, > > why isn't $i incrementing? > > here's sample of data file containing date and filename: > 021211 archive/summer.html > 021211 archive/summer.html > 021211 archive/tipsheet.html > 021211 arts.html > 021211 arts.html > 021211 arttherapy.html > 021211 arttherapy.html > 021211 arttherapy.html > 021211 award.html > 021211 award.html > 021211 award.html > 021211 award.html > 021211 bio.html > 021211 bio.html > > here's the code thus far: > > 1 #!/usr/bin/perl -w > 2 > 3 get_data(); > 4 > 5 #get data, split into date, and url > 6 sub get_data{ > 7 > 8 open(IN, "/dept/unxmkt/bin/hits_news/data.txt") > or die ("There is n > o file: $!\n"); > 9 > 10 open OUT, ">>/dept/unxmkt/bin/hits_news/log.txt") > or die ("no cant write to out file $!\n"); > 11 > 12 my @url = (); > 13 my $line = 0; > 14 my $date = 0; > 15 my $num = 0; > 16 > 17 while ($line=<IN>) { > 18 chomp($line); > 19 ($date, @url)=split(/ /, $line); > 20 > 21 $num = scalar(@url); > 22 print ("num = $num\n"); > 23 > 24 for ($i=0; $i<$num; $i++){ > 25 print ("$i = $url[$i]\n"); > 26 } > 27 > 28 } > 29 > 30 > 31 > 32 close IN; > 33 close OUT; > 34 > 35 } #end get_data > > > > > output: > num = 1 > 0 = archive/summer.html > num = 1 > 0 = archive/summer.html > num = 1 > 0 = archive/tipsheet.html > > thanks for any help, > Pam > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
