You can use glob to find all the file names matching that format. I'll use POSIX::strftime to generarte the glob pattern with today's date. Given the file names, I'll slurp each and count the number of matches to some $re.

use POSIX 'strftime'; my $date = strftime '%Y%m%d', localtime; my $re = qr/whatever/; my $count = 0; for (glob "/path/to/*$date*") { local $/; # to slurp open my $fh, '<', $_ or warn $! and next; my $content = <$fh>; close $fh; $count += () = $content =~ /$re/g; } print $count,$/;

The odd construction where $count is incremented is a common perl idiom for getting a list of matches and counting them. It places the bind-and-match in list context, then the resulting list is evaluated in numeric scalar context. Be cautious about capturing in $re. Multiple captures will produce extra elements in the list.

After Compline,
Zaxo


In reply to Re: opening multiple files by Zaxo
in thread opening multiple files by sandeep

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.