Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: package magic or am I missing something?

by janx (Monk)
on Jun 18, 2002 at 20:00 UTC ( [id://175484]=note: print w/replies, xml ) Need Help??


in reply to package magic or am I missing something?

That's a good one.

It's a wonderful example of indirect object syntax. See The Bag'o'Tricks.
Use B::Deparse shows what happens:
Update: Rather

perl -MO=Deparse
shows what happens:
sub FOO::new { package FOO; use strict 'refs'; } sub FOO::try { package FOO; use strict 'refs'; print "Trying...?\n"; } use strict 'refs'; do { 'FOO'->new }->try;

As you see, the

do { 'FOO'->new }
gives you the object, which you can happily call a method on ;-)

Kay

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-16 06:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found