i think qq is correct here when he says you should try using a CSV module from CPAN.DBD::CSV or DBD::AnyData. With it you could just use a select style query on the file from STDIN. like so ...

use DBD::CSV; my $input = "test.csv"; my $dbh = DBI->connect(qq{DBI:CSV:}); $dbh->{'csv_tables'}->{'info'} = { 'file' => "$input", 'eol' => "\n", 'col_names' => ["ID", "date"]}; my $sth = $dbh->prepare("SELECT * FROM info WHERE date=?"); print "Enter a date to seach for MM/DD/YYYY: "; my $date = <STDIN>; chomp($date); $sth->execute($date); my @array; while(@array = $sth->fetchrow_array){ print "$array[0], $array[1]\n"; }
with the test.csv being (example)
1,02/03/2004
2,09/04/1976
3,01/13/1998
4,02/04/2006
5,02/07/2004
6,02/03/2004
which should give you want you want

localhost% ./csv
Enter a date to seach for MM/DD/YYYY: 02/03/2004
1, 02/03/2004
6, 02/03/2004

update:I should pay more attention in examples. I formatted your date incorrectly. It will still work with your format.

In reply to Re: Re: Parsing a date from comma-delimited file by jaco
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.