in reply to Debugging Help!!!

Well I got your same errors, and narrowed it down to your regex in your parse_location sub. It dosn't return anything. Maybe one of the regex gurus can give you a better regex.
#!/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(&degrees_to_radians($lat), &degrees_to_radians($long)); + } else { return undef; } }

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Regular Expression Help!!
by Anonymous Monk on Apr 13, 2006 at 12:42 UTC
    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(&degrees_to_radians($lat), &degrees_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

      You're only passing HALF of what's needed to the function. It's expecting latitude and longitude. You're only giving it latitude (or longitude, I can't remember which).

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
        Did you run it by adding another value?