Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Glob strange behavior

by Anonymous Monk
on Aug 22, 2006 at 13:30 UTC ( #568838=note: print w/replies, xml ) Need Help??


in reply to Re^2: Glob strange behavior
in thread Glob strange behavior

Hi fellows, i would like to point out the different behavior of glob utilized in scalar context when the key is a variable or a literal.
WRONG my @sign_arr=('A1' .. 'A9'); for my $sign (@sign_arr) { my $filename = <*$sign*.pkl>; print "$filename\n" if defined($filename); } # OUTPUT: # file_A1_.pkl # file_A3_.pkl # file_A5_.pkl # file_A7_.pkl # file_A9_.pkl # RIGHT my $filename; $filename = <*A1*.pkl>; print "$filename\n" if defined($filename); $filename = <*A2*.pkl>; print "$filename\n" if defined($filename); $filename = <*A3*.pkl>; print "$filename\n" if defined($filename); $filename = <*A4*.pkl>; print "$filename\n" if defined($filename); $filename = <*A5*.pkl>; print "$filename\n" if defined($filename); $filename = <*A6*.pkl>; print "$filename\n" if defined($filename); $filename = <*A7*.pkl>; print "$filename\n" if defined($filename); $filename = <*A8*.pkl>; print "$filename\n" if defined($filename); $filename = <*A9*.pkl>; print "$filename\n" if defined($filename); # OUTPUT: # file_A1_.pkl # file_A2_.pkl # file_A3_.pkl # file_A4_.pkl # file_A5_.pkl # file_A6_.pkl # file_A7_.pkl # file_A8_.pkl # file_A9_.pkl
A bug?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://568838]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2020-10-24 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (247 votes). Check out past polls.

    Notices?