in reply to When warnings get in the way
But this has limitations (like if getFoo() returns 0).my $foo = getFoo() || ''; if ($foo =~ /bar/ ){ ... }
my $foo = getFoo() ? 1 : 0; if ( $foo ){ ... }
$a // $b; # short for: defined($a) ?? $a :: $b $pi //= 3; # so could do (of course perl6 only): if( $foo // '' eq "true" ){ ... } # or my $foo = getFoo(); $foo //= ''; if( $foo eq "true" ){ ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: When warnings get in the way
by ysth (Canon) on Apr 22, 2005 at 17:14 UTC |