Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: package magic or am I missing something?

by janx (Monk)
on Jun 18, 2002 at 20:00 UTC ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2023-04-01 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?