in reply to Bless and Do
Since Perl does not have the concept of an anonymous scalar ref (in contrast to {} and []), your kludge is one way of getting that. The best reason to use it is because it works. The worst reason is that you had to ask the question; it doesn't scan unless you know the trick. Were I to write it, I'd probably go with the more verbose:
If you really want to use a do, you could alsomy $variable; ANON_SCALAR_BLOCK: { my $x = 49; $variable = bless \$x, 'Rates::Notification'; }
which I think scans better.my $variable = do { my $x = 49; bless \$x, 'Rates::Notification'; };
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bless and Do
by Anonymous Monk on Jun 17, 2014 at 20:20 UTC | |
|
Re^2: Bless and Do on the outside
by Anonymous Monk on Jun 18, 2014 at 00:00 UTC | |
by LanX (Saint) on Jun 18, 2014 at 00:25 UTC | |
by Anonymous Monk on Jun 18, 2014 at 01:25 UTC | |
by LanX (Saint) on Jun 18, 2014 at 01:37 UTC | |
by Anonymous Monk on Jun 18, 2014 at 01:55 UTC |