Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In my folder C:/dataset/
I have the following files:

20051026ng3_Well A1_21593.pkl
20051026ng3_Well A2_21593.pkl
20051026ng3_Well A3_21593.pkl
20051026ng3_Well A4_21593.pkl
20051026ng3_Well A5_21593.pkl
20051026ng3_Well A6_21593.pkl
20051026ng3_Well A7_21593.pkl
20051026ng3_Well A8_21593.pkl
20051026ng3_Well A9_21593.pkl
To search for filenames containing alphanumeric signatures like A1, A2 etc. I have written the following:
#!/usr/bin/perl -w use strict; my $path='C:/dataset/'; my @sign_arr=('A1', 'A2', 'A3','A4', 'A5', 'A6', 'A7', 'A8', 'A9'); foreach (@sign_arr) { if(defined (my $filename=(glob("$path*$_*.pkl")))) {print "$filename $_\n"} else {print "not found $_\n";} }
The ouput I get is following:

C:/dataset/20051026ng3_Well A1_21593.pkl A1

Not found A2

C:/dataset/20051026ng3_Well A3_21593.pkl A3

Not found A4

C:/dataset/20051026ng3_Well A5_21593.pkl A5

Not found A6

C:/dataset/20051026ng3_Well A7_21593.pkl A7

Not found A8

C:/dataset/20051026ng3_Well A9_21593.pkl A9

I wonder how this small code could generate this results why are not all filenames containing the signatures A1, A2 etc. found? Thank you for your help.

2006-08-21 Retitled by holli, as per Monastery guidelines
Original title: 'Glob strange bahavor'

In reply to Glob strange behavior by tamaguchi

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2020-10-20 20:49 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (210 votes). Check out past polls.