Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Shortcut operator for $a->{'b'}=$b if $b;

by radiantmatrix (Parson)
on Sep 20, 2005 at 17:43 UTC ( #493548=note: print w/ replies, xml ) Need Help??


in reply to Shortcut operator for $a->{'b'}=$b if $b;

You could abstract $b away into a sub (I'm assuming you're using it as a placeholder for a complex operation), and do something like:

sub b { return $b; } b() and $a->{'b'} = b();

I guess I don't really understand where your "way too verbose" is coming from; it would help if I could see a more involved example of the code you're attempting to simplify.

<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law


Comment on Re: Shortcut operator for $a->{'b'}=$b if $b;
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2015-07-28 16:08 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 (258 votes), past polls