SPUG: new member (and learner) w/ ONE quick syntax question
Creede Lambard
creede at penguinsinthenight.com
Mon Jun 24 14:50:47 CDT 2002
On Mon, 24 Jun 2002, Baker, Stephen M wrote:
> when using the ternary operator ?, is the syntax:
>
> expression ? if_true : if_false;
>
> possible to modify so that if_true or if_false are compound
> expressions??
You can if you do it like this:
my $x = $expression ? true_sub() : false_sub();
sub true_sub {
. . . do stuff . . . .
}
sub false_sub {
. . . do stuff . . .
}
$x will contain the return value of whichever subroutine runs, which value
$you may or may not care about.
--
* .~. `( ---------------------------------------------------------------
` / V \ . Creede Lambard : There are no walls or borders;
/( )\ creede at penguinsinthenight.com : you don't need windows or gates
^^-^^ ---------------------------------------------------------------
Perl Programmer and Linux Sysadmin, reasonable rates. Inquire within.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list