On Thu, Aug 02, 2001 at 03:00:24PM -0400, Bob Showalter wrote:
> I played around with this a bit and found that:
>
> perl -e 'print scalar(glob("*")) for (1..2)'
>
> prints two different files, while
>
> perl -e 'print scalar(glob("*")), scalar(glob("*"))'
>
> prints the same file twice. I tried this on 5.005_03 and 5.6.1.
>
> Wonder why? Seems like its related to the loop context and not merely
> to scalar context.
It has to do with it being the same operator; you're effectively starting a
new glob with the second scalar(glob '*'). I assume there is some context
assigned to the op code itself. Consider a similar example to your for
loop:
{
my $file = glob('*');
last unless defined($file);
print $file;
redo;
}
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]