Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Anonymous Monk
on Jul 03, 2011 at 17:36 UTC ( #912551=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Locator to Lat/Long code: works, but is inelegant
in thread Locator to Lat/Long code: works, but is inelegant

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.


Comment on Re^3: Locator to Lat/Long code: works, but is inelegant
Download Code
Re^4: Locator to Lat/Long code: works, but is inelegant
by ForgotPasswordAgain (Deacon) on Jul 03, 2011 at 22:35 UTC
    Defining a sub also "declares" it:
    $ perl -le "sub f{warn@_} f 1" 1 at -e line 1.

      Defining a sub also "declares" it

      Except when it declares it too-late for the parser to notice

      The OP uses parens, so the parser doesn't need a "forward" declaration or re-arranging of sourcecode

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-07-29 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (223 votes), past polls