while(<@thisArray>)
Does anyone know what this would do exactly? We were just having a discussion on it as it's the code is usually something like:
while(<STDIN>)
It'll iterate through files names matched to patterns in @thisArray
.
Result of perl -MO=Deparse -e '1 while(<@thisArray>)'
shows that <>
is converted to glob
:
use File::Glob ();
'???' while defined($_ = glob(join($", @thisArray)));
From glob
manual:
In scalar context, glob iterates through such filename expansions, returning undef when the list is exhausted.
Default value for $"
is space, therefore multiple patterns from @thisArray
will be joined into single string and then splitted back by space inside glob
:
Note that glob splits its arguments on whitespace and treats each segment as separate pattern.
<@thisArray>
works as glob(@thisArray)
. So it gives a list of all files matching the members of the array.
If an element of the array doesn't match a file, the element itself is returned.
See perlop:
If what's within the angle brackets is neither a filehandle nor a simple scalar variable containing a filehandle name, typeglob, or typeglob reference, it is interpreted as a filename pattern to be globbed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With