Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: variable processing and checking in one statement

by ig (Vicar)
on Aug 07, 2012 at 04:37 UTC ( #985875=note: print w/replies, xml ) Need Help??


in reply to variable processing and checking in one statement

How about

doSthWith(checkFn($test));

Have checkFn return the passed data if all is well, or undef if not and have doSthWith check its arguments.

Or, incorporate the check into doSthWith - depending on where you want to localize the knowledge about the condition, and how you want to handle the race between the check and what you do with $test

And, I don't advocate this but find the range of possibilities interesting and can't seem to stop myself from updating:

sub { doSthWith($_[0]) if(checkFn($_[0])); }->($test);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985875]
help
Chatterbox?
[choroba]: Good morning! I'll be mostly absent today, a day off at work, children have concerts and other activities...
[Corion]: Hi choroba! Yay, day off sounds great! I hope the performances of the kids go well!

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-12-12 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (327 votes). Check out past polls.

    Notices?