Ok , thanks for the input.. but the thing is i have a file for each half hour interval, with upto 10 seperate readings..

I have put this ugly looking thing together.. which does seem to work..

use strict; my $input = "quotes.txt"; my ($quote,$time); my $actualquote; my $actualtime; my $hour; my $minute; my $second; my $picksecond; open(DATAFILE, "$input") || die("Can't open $input:!\n"); $picksecond =1; while (<DATAFILE>) { chomp $_; ($quote,$time) = split(",", $_); ($hour,$minute,$second) = split(":",$time); if ($second==0) {$actualtime=$time; $actualquote=$quote;$picksecond=99;} if ($second>$picksecond) {$picksecond=$second;$actualtime=$time; $actualquote=$quote;} print "$quote\t$time\t$second\n"; } print "$picksecond\t$actualtime\t$actualquote\n";

Does anyone care to comment on my code..??

i have another outstanding issue..

when i have a messed up time field e.g 17:30:07fg

how do i get the split command to ignore any characters after the 2 seconds digit? thanks.

conal.

In reply to Re: reading a delimited file and selecting values from it by Conal
in thread reading a delimited file and selecting values from it by Conal

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.