Rory has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File name filtering with ^ ?
by cdarke (Prior) on Mar 19, 2007 at 22:14 UTC | |
|
Re: File name filtering with ^ ?
by Anno (Deacon) on Mar 19, 2007 at 22:10 UTC | |
|
Re: File name filtering with ^ ?
by Bro. Doug (Monk) on Mar 19, 2007 at 22:19 UTC | |
by xicheng (Sexton) on Mar 20, 2007 at 05:50 UTC |