Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: Dynamic names

by 7stud (Deacon)
on Nov 17, 2010 at 23:08 UTC ( #872084=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Dynamic names
in thread Dynamic names

Hi, I have another question about that do{} construct. Is there any reason to use a do construct and not:

bless \my $anon, $class;

or the even easier to type:

bless {}, $class;


Comment on Re^4: Dynamic names
Select or Download Code
Replies are listed 'Best First'.
Re^5: Dynamic names
by cdarke (Prior) on Nov 18, 2010 at 10:22 UTC
    The first bless \my $anon, $class; retains the name $anon for the rest of the code block - it is no longer anonymous.

    The second bless {}, $class; constructs an anonymous hash, which I believe uses more memory. I cannot claim I invented the use of the do{ } construct in this way, I stole it from TheDamian.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-29 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls