If the format of the dates in your text file are consistant, there may be no need to parse the dates in it...

use warnings; use strict; use Date::EzDate; #Date::EzDate can parse several date formats w/o intervention, #so let's make life easy for end-users by making the input format #flexible. my $date_in = 'Mar 13, 04'; my $date = Date::EzDate->new($date_in) or die "Couldn't parse the date '$date_in'.\n"; #convert the date to a string that will match the consistent format #in our DATA file. Note that this will only work if the date format #in the file is, in fact, consistent. my $match_date = $date->{'%f/%h/%Y'}; print "Looking for matches on $match_date:\n"; while (<DATA>) { #a regex match might work as well as splitting #note that there is no need to split the date since we're just #matching strings print if $match_date eq (split)[2]; } 1; __DATA__ blah blah 1/Feb/2004 Gamera blah blah 13/Mar/2004 Godzilla blah blah 22/Jan/2004 Mothra blah blah 3/Apr/2004 Baragon blah blah 13/Feb/2004 Guiron blah blah 5/Feb/2004 King Ghidorah blah blah 27/Mar/2004 Legion blah blah 13/Mar/2004 Mechagodzilla
Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

In reply to Re: Parsing a date from comma-delimited file by Art_XIV
in thread Parsing a date from comma-delimited file by playing18

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.