Hi Monks!
I need to check if some code letter is part of a file name, and if its not, ignore the file, having issues trying to do this without a loop since I am already in a "for" loop. If I have no choice I would use another loop.
Here is a sample code to show what I am trying to do:
...
my @array_code = qw(x-01 x-02 x-03 x-04 v-05 v-06 v-07 x-08 x-09 x-10
+x-11);
for my $file (read_dir( $dir_list, prefix => 1 )) {
#files will be: 1234567_x-01_2013_03.txt 1234667_x-03_2013_03.txt
+ 0034567_y-01_2013_03.txt 1234567_v-01_2013_03.txt 1233567_v-05_2013_
+03.txt 1234567_x-55_2013_03.txt
next if grep { /$file/ } @array_code; # not working
next if(! -f $file || -s $file < $min_size) ;
if(-s $file <= $max_size) {
push @files, $file;
}else {
push @bigsize_files, $file;
}
}
...
Thanks for the help!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.