true false ? : expression thingy
- From: "Bigus" <someone@xxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 11:40:24 +0100
I'm not sure what this method is called, which is perhaps why I've had no
luck when searching around the web for info on it, but when you want a
1-line alternative to an if...else.. construct, you can use the following
syntax:
$ctr > 3 ? $text = "yes" : $text = "no";
that works fine, however, when I try this:
my $incsubs;
$line =~ /\ts/i ? $incsubs = 0 : $incsubs = 1;
it doesn't work.. well, $incsubs equals 1 regardless whereas it works in the
standard if...else.. construct.
I guess this is because the regular expression doesn't return true/false, or
sth like that.. is there a "trick" you can use to make this type of method
work with regexps?
Bigus
.
- Follow-Ups:
- Re: true false ? : expression thingy
- From: Anno Siegel
- Re: true false ? : expression thingy
- Prev by Date: Re: Read first few lines from command output
- Next by Date: Re: tied hash
- Previous by thread: FAQ 4.65 How can I store a multidimensional array in a DBM file?
- Next by thread: Re: true false ? : expression thingy
- Index(es):
Relevant Pages
|