develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #96116] File::Glob ':glob' causes infinite loop

Thread Next
From:
Father Chrysostomos via RT
Date:
October 31, 2011 13:18
Subject:
[perl #96116] File::Glob ':glob' causes infinite loop
Message ID:
rt-3.6.HEAD-31297-1320092308-25.96116-14-0@perl.org
On Wed Oct 26 08:55:56 2011, tom christiansen wrote:
> Given:
> 
>     % mkdir /tmp/sandbox
>     % cd /tmp/sandbox
>     % touch "space file" space file
> 
>     % perl -E 'say for <*e f*>'
>     file
>     space
>     space file
>     file
> 
>     % perl -E 'say for <"*e f*">'
>     space file
> 
>     % perl -E '$v = "e"; say for <"*{$e} f*">'
>     space file
> 
> No code needs changing, only doc.  I thus propose:

Some of that was already covered in perlfunc.  But I’ve taken part of
your text and added it with commit a91bb7b.

> 
>     The C<glob> function grandfathers the use of whitespace to separate
>     multiple patterns such as C<< <*.c *.h> >>.  If you want to glob
>     filenames that might contain whitespace, you'll have to use extra
>     quotes around the spacey filename to protect it.  For example, to
>     glob filenames that have an “C<e>” followed by a space followed by
>     an “C<f>”, use either of:
> 
>         @spacies = <"*e f*">;
>         @spacies = glob  '"*e f*"';
>         @spacies = glob q("*e f*");
> 
>     If you had to get a variable through, you could do this:
> 
>         @spacies = glob   "'*${var}e f*'";
>         @spacies = glob qq("*${var}e f*");
> 
>     Alternately, you can use the C<File::Glob> module directly, so 
>     for details, see its manpage.  Calling C<glob> or the C<< <*> >>
>     operator automatically C<use>s that module, so if the module
>     mysteriously vaporizes from your library, an exception is raised.
> 
> --tom
> 


-- 

Father Chrysostomos


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About