Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Bless and Do on the outside

by Anonymous Monk
on Jun 18, 2014 at 00:00 UTC ( #1090225=note: print w/ replies, xml ) Need Help??


in reply to Re: Bless and Do
in thread Bless and Do

If you really want to use a do, you could also

my $variable = do { my $x = 49; bless \$x, 'Rates::Notification'; };
which I think scans better.

Yes, do on the outside always scans better, its like creating a sub and calling it immediately,  (sub { ... })->(); except prettier :)


Comment on Re^2: Bless and Do on the outside
Select or Download Code
Re^3: Bless and Do on the outside
by LanX (Canon) on Jun 18, 2014 at 00:25 UTC
    > Yes, do on the outside always scans better, its like creating a sub and calling it immediately, (sub { ... })->(); except prettier :)

    To avoid misunderstandings: It's similar but not identical!

    DB<106> sub tst { (sub { return 5 })->(); return 10 } DB<107> tst() => 10 DB<108> sub tst { do { return 5 }; return 10 } DB<109> tst() => 5

    Like with map and grep is the block following do not an anonymous sub!

    Cheers Rolf

    (addicted to the Perl Programming Language)

      To avoid misunderstandings: It's similar but not identical!

      "Like" means "similar" I think dictionary can agree!

      Like with map and grep is the block following do is not an anonymous sub!

      Of course we're discussing looks!

        > I think dictionary can agree!

        Nope, check dictionary for "like...except..." .

        Cheers Rolf

        (addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

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 2014-07-28 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (195 votes), past polls