Hi Monks!
This code is generating a error that I believe that it is occurring on the regular expression from the "sub parse_location", can someone take a look at it and let me know where this error "Use of uninitialized value in concatenation (.) or string" is coming from?
Here is the actual code.
#!/perl/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;
}
}
Thanks for the big Help!
20060413 Corion Reparented under Re: Debugging Help!!!, as it's a continuation of this thread
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.