Hello brothers,

I've stumbled across the following code:

my $mask = shift; my @folders = glob("$mask"); if (scalar(@folders) == 0) { return undef; }
It seems unelegant and unrobust to me, so I investigated a little bit further. To my surprise I found a strange behaviour of glob, when a glob is given that does not match but that does not contain wildcards also. Given the folowing examples:
@t1 = glob('*1'); @t2 = glob('1'); @t3 = glob('file2'); @t4 = glob('*3');
assume you have the files file1 and file2 in the directory glob is searching, the returns are 'file1' for @t1, '1' for @t2, 'file2' for @t3 and the empty list for @t4.

The behaviour for @t2 is what seems odd/annoying. In my opinion it should be empty, as the current semantics make it indistinguishable from the @t3 case - which is correct imho.

Please tell me, that I've found a bug that is soon to be fixed... :-}

Bye
 PetaMem


In reply to Isn't glob annoying? (somehow) by PetaMem

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.