in reply to Debugging Help!!!
#!/usr/bin/perl -w use strict; # convert a string which looks like "34:45:12N,15:34:10W" into a pair # of degrees. Also accepts "34.233N,90.134E" etc. my ($lat1,$long1) = parse_location('34:45:12N'); print "$lat1, $long1\n"; sub parse_location { my($str) = @_; print "$str\n"; my($lat,$long); if ($str =~ /^([0-9:.\260'"d -]*)([NS])[, ]+([0-9:.\260'"d -]*)([E +W])$/i) { return undef if (!defined($lat = &parse_degrees($1))); $lat *= (($2 eq "N" || $2 eq "n") ? 1.0 : -1.0); return undef if (!defined($long = &parse_degrees($3))); $long *= (($4 eq "E" || $4 eq "e") ? 1.0 : -1.0); return(°rees_to_radians($lat), °rees_to_radians($long)); + } else { return undef; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Regular Expression Help!!
by Anonymous Monk on Apr 13, 2006 at 12:42 UTC | |
by japhy (Canon) on Apr 13, 2006 at 13:37 UTC | |
by Anonymous Monk on Apr 13, 2006 at 13:42 UTC | |
by japhy (Canon) on Apr 13, 2006 at 13:45 UTC | |
by Anonymous Monk on Apr 13, 2006 at 14:03 UTC |