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.You seem to know what you want, so it's just a case of following your spec...
my @data = split /\n/, <<EOS; 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 EOS for ( @data ) { if ( my ( $quote, $time, $comment ) = m{ ^ # start of string (\d\.\d{5}) # a digit, dot and 5 more digits \s, # a space and a comma (\d\d:\d\d:\d\d) # an 8 character time \s* # some spaces (.*) # everything else's a commment $ # end of string }x ) { print "$quote / $time", $comment ne '' ? " / $comment" : '', "\n"; } }
Output:
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.57172 / 17:30:08 1.57176 / 17:30:10
Update:
See perlre and perlretut for the details
In reply to Re: handling erronous input
by FunkyMonk
in thread handling erronous input
by Conal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |