in reply to dealing with whitespace and using chop when reading delimited files
while (<DATAFILE>) { unless (m{^(.*?)\s*,([\d:]+)}) { warn "$.: unrecognizable line: $_"; next; } my $data = $1; my $time = $2; # ... continue processing ... } # output follows: __END__ 1.4567,11:00:00 1.4571,11:00:01 3: unrecognizable line: , 1.4567,11:58:00 5: unrecognizable line: 1.4566 , 1.5555,11:43:00 7: unrecognizable line:
Note, the regular expression is very liberal in what it will accept which is the way I like to do things. You can make it more exacting if you find it necessary.
|
|---|