Skip to content

Commit

Permalink
perlfunc/glob: Explain use of quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Christiansen authored and Father Chrysostomos committed Oct 31, 2011
1 parent a3f52e2 commit a91bb7b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pod/perlfunc.pod
Expand Up @@ -2536,6 +2536,19 @@ Note that C<glob> splits its arguments on whitespace and treats
each segment as separate pattern. As such, C<glob("*.c *.h")>
matches all files with a F<.c> or F<.h> extension. The expression
C<glob(".* *")> matches all files in the current working directory.
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*");

If non-empty braces are the only wildcard characters used in the
C<glob>, no filenames are matched, but potentially many strings
Expand Down

0 comments on commit a91bb7b

Please sign in to comment.