M
Mike Flannigan
Maybe it's just me, but I don't find the documentation on
sprintf to be very enlightening. I've read it many times
and still can't figure it out, despite being a math kinda
guy.
I don't expect anybody here to explain it to me. It
would take way too much typing. I have the Camel
book and I'll figure it out today or tomorrow.
But one thing you could help me with is how best to
match a simple number with a decimal point (fp number?).
I want to match the 21.33 and 8.75 on the first line below.
I am using this right now:
/^\s{9}(\d{1,3})\s*[NS](\d+).\s+(\d+\.\d+)\'[WE](\d+).(\d+\.\d+)\'/i;
Does (\d+\.\d+) seem like a good way to you'all? Surely
there is a simpler way. I don't want a string, I want the
number (21.33).
Then I thought to do come calculations and make the
result a number like 99.1458330000 (10 digits after
the decimal point) I could use:
$l = $4+($5/60);
$m = sprintf %.10f, $l;
The error I get is
"Number found where operator expected at . . . line 28,
near "%.p" . . . "
I've tried a bunch of things, but can't fix the problem.
Mike
__DATA__
10 N29° 21.33'W99° 8.75' 2.32 mi
11 N29° 20.16'W99° 10.63'23.55 mi
12 N29° 18.75'W99° 34.02' 8.94 mi
13 N29° 16.76'W99° 42.63' 7.64 mi
sprintf to be very enlightening. I've read it many times
and still can't figure it out, despite being a math kinda
guy.
I don't expect anybody here to explain it to me. It
would take way too much typing. I have the Camel
book and I'll figure it out today or tomorrow.
But one thing you could help me with is how best to
match a simple number with a decimal point (fp number?).
I want to match the 21.33 and 8.75 on the first line below.
I am using this right now:
/^\s{9}(\d{1,3})\s*[NS](\d+).\s+(\d+\.\d+)\'[WE](\d+).(\d+\.\d+)\'/i;
Does (\d+\.\d+) seem like a good way to you'all? Surely
there is a simpler way. I don't want a string, I want the
number (21.33).
Then I thought to do come calculations and make the
result a number like 99.1458330000 (10 digits after
the decimal point) I could use:
$l = $4+($5/60);
$m = sprintf %.10f, $l;
The error I get is
"Number found where operator expected at . . . line 28,
near "%.p" . . . "
I've tried a bunch of things, but can't fix the problem.
Mike
__DATA__
10 N29° 21.33'W99° 8.75' 2.32 mi
11 N29° 20.16'W99° 10.63'23.55 mi
12 N29° 18.75'W99° 34.02' 8.94 mi
13 N29° 16.76'W99° 42.63' 7.64 mi