It wouldn't be hard to imagine a situation where you want test the returns from a list of functions, attempted in sequence until one of them returns true, and then do some specific block of code depending on which one returned true. In other words, something like this could be called for:
my @params = ...; # whatever sets the context...
if ( my $x = function_1( @params )) {
# do something with the return value from function_1
}
elsif ( $x = function_2( @params )) {
# do something with the return value from function_2
}
# ... and so on.
I don't know if this is the OP's situation, but it would motivate the kind of approach the OP is asking about. There might be other idioms for doing this sort of thing, but doing it this way seems reasonable.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.