" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 4:54 PM
Subject: Re: problems with scalar(@array)
> my final goal is to loop through each filename and count how many times
each filename appears, example:
> archive/summer.html 2
> arts.
close IN;
}
#end get_data
HTH,
Rob
- Original Message -
From: "Pam Derks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 4:54 PM
Subject: Re: problems with scalar(@array)
> my final goal is to loop through each filename
]
> Subject: Re: problems with scalar(@array)
>
>
> > my final goal is to loop through each filename and count how many
> > times each filename appears, example: archive/summer.html 2
> arts.html
> > 2 arttherapy.html 3.
> >
> >
> > for right now,
> my final goal is to loop through each filename and count how many times
> each filename appears, example: archive/summer.html 2
> arts.html 2
> arttherapy.html 3.
>
>
> for right now, I'm just trying to loop through the array @url.
> Next step would be to compare whats in $line with what's in $ur
>> On Tue, 17 Dec 2002 11:59:46, <[EMAIL PROTECTED]> said:
> Also, you might change 'scalar(@url)' to '$#url' for simplicity.
More than just simplicity:
void:chris~ % perl -le '@a=(5,10,15,20); print scalar @a,"\n",$#a'
4
3
$# signifies the index of the last element in an arr
my final goal is to loop through each filename and count how many times each filename
appears, example:
archive/summer.html 2
arts.html 2
arttherapy.html 3.
for right now, I'm just trying to loop through the array @url.
Next step would be to compare whats in $line with what's in $url[$i] and if
> Howdy,
>
> why isn't $i incrementing?
> >24for ($i=0; $i<$num; $i++){
>25 print ("$i = $url[$i]\n");
>26}
>27
It's working perfectly! :)
21$num = scalar(@url);
22print ("num = $num\n");
output:
num = 1
0 = archive
Hi Pam
$i is incrementing. Your loop starts with $i at zero, as shown by your
trace. The print statement executes, $i is incremented to 1, your test $i <
$num is made and found to be false ($i == $num) so the loop executes.
I'm not sure exactly what you're wanting. The line split(/ /, $line) will
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