Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Bless and Do

by LanX (Chancellor)
on Jun 17, 2014 at 16:08 UTC ( #1090164=note: print w/replies, xml ) Need Help??


in reply to Bless and Do

One can bless only references, but all kind of references!

While the "standard" is to bless hash-refs, there are occasions where blessing array-refs or code-refs or even scalar-refs make much sense.

BUT there is no "literal notation" for scalar-refs (like [...] or sub{...} )!

That's why a do construct is used, to avoid temporary variables¹.

IIRC does TheDamian talk about this in his (recommended!) PBP book.

HTH! :)

Cheers Rolf

(addicted to the Perl Programming Language)

update

¹) like

$temp_scalar = 5; my $scalar_ref = \$temp_scalar; bless $scalar_ref, ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090164]
help
Chatterbox?
[1nickt]: Wow. I had heard about the chips on HP cartriddges but not that issue. I rejected HP's equivalent laptop becuase of build quality, very plasticky keyboard. And I believe HP is the champon of bloatware, too.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-03-27 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.