I'm new to this forum.

This is my first post!

I have an issue what I am trying to get a list of filenames and filter out some filenames.

For instance in a subdirectory "temp" I have the following file names:

hello.pl hTllo.pl hVllo.pl hQllo.pl

I want to retrieve a list of file names but not include filenames with the second character of 'T' or 'V'.

In other words I want the file names:

hello.pl hQllo.pl

The code I've written is:

######################################################## #!/usr/bin/perl -w my @{Files}; my ${FileName} = "h[[^TV]]*.pl"; my ${f} = ""; @Files = <temp\${FileName}>; printf ("\n##############[ ${FileName} ]####################\n"); foreach ${f} (@Files) { printf("${f}\n"); } printf ("##################################\n"); ########################################################

The response I get is:

##############[ h[[^TV]]*.pl ]#################### temp\hTello.pl temp\hVello.pl ##################################

The references tell me the '^' character is a NOT and should filter out the T and V characters... but does not.

Any suggestions?

20070320 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips


In reply to File name filtering with ^ ? by Rory

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.