I find the phrase "If non-empty braces are the only wildcard characters used in the glob" misleading because it makes it sound like there are many wildcard chars to choose from, rather than just * and braces. So that would be "If there is no * in the glob". You also demonstrated that even if there are * in the strings, it can potentially return strings without matching files, because glob("PATTERN_A PATTERN_B") is the same as (glob("PATTERN_A"), glob("PATTERN_B")).

That said, the other difference between glob and qw is interpolation, and quotes. You can't have an element with a space inside qw, but you can in glob. And glob interpolates while qw does not. IIRC ruby has each quoting construct in pairs, interpolating or non interpolating, so you can insert a few variables in a list of words. glob is tricky though, because interpolation is done first, and spaces and quotes in your variables might not do what you want:

use Data::Dump qw( pp ); my $interpolate = "A"; my $trap = "'X Y' Z"; pp qw( $interpolate B 'C D' "E F" $trap); pp < $interpolate B 'C D' "E F" $trap \Q$trap>; __DATA__ ("\$interpolate", "B", "'C", "D'", "\"E", "F\"", "\$trap") ("A", "B", "C D", "E F", "X Y", "Z", "'X\\ Y'\\ Z")

So as a conclusion: qw works exactly like a single quoted string splited on whitespace, but glob can be tricky if braces, *, $, @ or quotes are present in the string. Also qw accepts newlines where glob doesn't.


In reply to Re: Why are glob patterns without metacharacters returned by Eily
in thread Creating arrays with glob patterns without metacharacters by Lotus1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.