Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Locator to Lat/Long code: works, but is inelegant

by Anonymous Monk
on Jul 02, 2011 at 17:36 UTC ( [id://912481]=note: print w/replies, xml ) Need Help??


in reply to Locator to Lat/Long code: works, but is inelegant

Looks adequately elegant to my eyes :) Maybe you wish to compare to these alternate implementations

Ham::Locator - Convert between Maidenhead locators and latitude/longitude.

Astro::Coord::ECI - Manipulate geocentric coordinates

Small style point, there is no need for

sub latlong2maidenhead; sub maidenhead2latlong;
in your code. You might wish to compare your program to this template see (tye)Re: Stupid question (and see one discussion of that template Re^2: RFC: Creating unicursal stars)

Replies are listed 'Best First'.
Re^2: Locator to Lat/Long code: works, but is inelegant
by Willard B. Trophy (Hermit) on Jul 03, 2011 at 14:26 UTC
    Aargh! Forgot about the zero'th rule of Perl programming: check CPAN first! I just got into the habit of sub declaration, because I remember warnings being generated if you didn't.

    -- 
    bowling trophy thieves, die!

      I just got into the habit of sub declaration, because I remember warnings being generated if you didn't.

      Its all about parens. If you use parens, no warnings. You use parens :)

      $ perl -le " f(1); sub f{warn@_} " 1 at -e line 1. $ perl -le " f 1 ; sub f{warn@_} " Number found where operator expected at -e line 1, near "f 1" (Do you need to predeclare f?) syntax error at -e line 1, near "f 1" Execution of -e aborted due to compilation errors. $ perl -le " sub f; f 1 ; sub f{warn@_} " 1 at -e line 1.
        Defining a sub also "declares" it:
        $ perl -le "sub f{warn@_} f 1" 1 at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://912481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found