in reply to 3 strings to join

You might find the following syntax a bit clearer.
if ( $b and $c ) { $string = "$a where $b and $c"; } elsif ( $b or $c ) { $string = "$a where " . ($b ? $b : $c) ; }
This relies on using the ternary operator: condition ? true : false Let's say you have the following line:
$x = $b ? 5 : 17;
If $b evaluates as true, $x will be set to 5. Otherwise, it will be set to 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

    actually I have seen it, but it's one of those things I read about and then say "what could I use that for?", move on, hit an issue and then someone as enlightened as yourself says "You could do this." and I have a small psychotic break (or satori, whatever you prefer :)

    ...and then the monk gained enlightenment?

    -- I'm a solipsist, and so is everyone else. (think about it)