Conal has asked for the wisdom of the Perl Monks concerning the following question:
I only want to use data like '1.57172 ,17:30:08 ' for my computation, e.g.. i want to disregard data that looks like ' 1.571 ,17: ' I would also like to use ' 1.57163 ,17:29:57 Simple Dealin ', if my code was capable of ignoring the data after the time.//input.txt 1.57163 ,17:29:57 Simple Dealin 1.57163 ,17:29:57 1.57163 ,17:29:57 1.57163 ,17:29:57 1.57163 ,17:29:57 1.57163 ,17:29:57 1.57163 ,17:29:57 1.571 ,17: 1.57172 ,17:30:08 1.57176 ,17:30:10
The code i have come up with isnt good enough, which is below..
What i need is for my code to only accept input of 1 digit before the decimal place and 5 after , a space, a comma.. then an 8 character time using : as a seperator that will ignore any data on the same line after the seconds.while (<DATAFILE>) { unless (m{^(.*?)\s*,([\d:]+)}) { next; } chomp $_; ($quote,$time) = split(",", $_); // do my computations chop($quote);chop($quote);
can anyone help me flush out this bug in my script please?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: handling erronous input
by FunkyMonk (Bishop) on Apr 06, 2008 at 15:39 UTC | |
by Conal (Beadle) on Apr 06, 2008 at 22:23 UTC | |
by FunkyMonk (Bishop) on Apr 06, 2008 at 22:57 UTC | |
by GrandFather (Saint) on Apr 06, 2008 at 23:35 UTC | |
by Conal (Beadle) on Apr 06, 2008 at 23:50 UTC | |
by ww (Archbishop) on Apr 07, 2008 at 02:55 UTC | |
by apl (Monsignor) on Apr 07, 2008 at 12:06 UTC | |
|
Re: handling erronous input
by swampyankee (Parson) on Apr 06, 2008 at 15:37 UTC |