Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Glob strange behavior

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


in reply to Glob strange behavior

Sorry if i duplicate my post but the previous one was under another reply. This is my first post (actually the second), i'm just a lurker :) 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://568846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-10-26 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (254 votes). Check out past polls.

    Notices?