in reply to Extracting coordinates
This is a general answer. I didn't review the code, but there's a simple and swift approach to parsing formatted data files. The data and delimiters are ALWAYS opposites. If you have a space delimted file, with 3 fields use:
if($line =~ /^(\S+)\s+(\S+)\s+(\S+)/) { @fields = ($1,$2,$3) } else { print "Regex Error on $line\n" }
If you have a colon delimted file, with 3 fields use:
if($line =~ /([^:]+):([^:]+):([^:]+)/) { @fields = ($1,$2,$3) } else { print "Regex Error on $line\n" }
\s is the opposite of
\S
: is the opposite of
Then you can manipulate individual fields.
Sean
|
|---|