I want to be able to process all files that follow the specific filenaming e.g. 2017_06_30_013901_0828900840_17062901D602BG So I want to process only files that contain *****************_0828900840_********D602BG with the help of the below code I was able to process all the files that have "D602BG". How can I achive my additional requirement within the same code.

foreach my $folder (@folders) { # glob the contents of the folder (to get the file names) my @contents = <$folder/*>; # For each filename in the list, if it matches foreach my $item ( @contents ) { if ($item =~ /C602DZB/){ #File name with specific +pattern open my $info, $item or die "Could not ope +n $item: $!"; while( my $line = <$info>) { if ($line =~ /Total/){ #Multiple pa +ttern match done push (@lines, $line); #Matching + lines pushed to an array } } } } }

In reply to Pick up specific file name by JobyJ

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.