in reply to 3 strings to join
This relies on using the ternary operator: condition ? true : false Let's say you have the following line:if ( $b and $c ) { $string = "$a where $b and $c"; } elsif ( $b or $c ) { $string = "$a where " . ($b ? $b : $c) ; }
If $b evaluates as true, $x will be set to 5. Otherwise, it will be set to 17.$x = $b ? 5 : 17;
(Sorry if I seem pedantic. Not sure if you'd seen it before).
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: (Ovid) Re: 3 strings to join
by jptxs (Curate) on Sep 29, 2000 at 02:23 UTC |