Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Bug or inconsitency? FQN of Package and sub name identical

by swampyankee (Parson)
on Nov 22, 2007 at 15:28 UTC ( #652390=note: print w/ replies, xml ) Need Help??


in reply to Bug or inconsitency? FQN of Package and sub name identical

Odd behavior when package and sub names are identical? My first suggestion is "don't do that." Perl is probably resolving its subs based, at least partly, on which ones it sees first, so it will use the first one it finds. I don't think this is either a bug or an inconsistency; it's a design decision. It does mean that the order subs are defined matters, which is not a concern unique to Perl: quite a few linkers do the same thing.


emc

Information about American English usage here and here.

Any Northeastern US area jobs? I'm currently unemployed.


Comment on Re: Bug or inconsitency? FQN of Package and sub name identical
Re^2: Bug or inconsitency? FQN of Package and sub name identical
by ysth (Canon) on Nov 22, 2007 at 16:32 UTC
    Yes, Foo-> compiles to (&Foo())-> if a sub Foo already exists; otherwise it's ("Foo")->:
    $ perl -wl sub Foo::new{"new in Foo"} sub Bar::new{"new in Bar"} print "before sub Foo: ", Foo->new; sub Foo {"Bar"} print "after sub Foo: ", Foo->new __END__ before sub Foo: new in Foo after sub Foo: new in Bar
    You can disambiguate by saying Foo::->new or "Foo"->new. I prefer the former.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-08-29 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls