Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am confused about filename wildcards using Perl. I want to call in a file to run a perlscript on. The filenames are always in the form: abc_code$12345.txt, but the numerals after the $ are always different. In a DOS environment, I can just call this file by saying abc_code$*.txt. How do I do this in a similar fashion in my perlscript? Thanks.

Replies are listed 'Best First'.
Re: filename wildcards
by jeroenes (Priest) on May 15, 2001 at 09:43 UTC
    Globbing is very much what you want. But watch out for the dollar sign, it has a special meaning in perl.
    my @matches = glob 'abc_code$*.txt';
    So don't use the "" delimiters here.

    Jeroen
    "We are not alone"(FZ)

      THANKS!

      THANKS!

      sub Wipe_Out { unlink glob "hosts-*.cfg"; unlink "hostgroup.cfg"; }
Re: filename wildcards
by rchiav (Deacon) on May 15, 2001 at 07:18 UTC
    Actually, it's done in a very similar way. Look at glob for a full description.

    Hope this helps..
    Rich