Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: To glob or not to glob

by choroba (Cardinal)
on Jan 08, 2018 at 10:43 UTC ( [id://1206895]=note: print w/replies, xml ) Need Help??


in reply to To glob or not to glob

Another potential danger of glob is its usage in scalar context. It should return the matches one by one, but the iterator is assigned to the place where glob is used and isn't reset when a new parameter is supplied to it:
#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; open my $fh, '>', $_ for my @files = qw( a1 a2 b1 b2 ); for my $mask ('a*', 'b*') { while (my $f = glob $mask) { say $f; last } } unlink @files;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found