in reply to Code blocks with ternary operator or trailing conditionals
Just use do blocks:
#! perl use strict; use warnings; my $x = 42; do { print "Hello "; print "world!\n"; } if 7 < $x; 43 > $x ? do { print "Yes, "; print "it is!\n"; } : do { print "No, "; print "it isn't!\n"; };
Output:
12:46 >perl 865_SoPW.pl Hello world! Yes, it is! 12:46 >
See do.
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Code blocks with ternary operator or trailing conditionals
by puterboy (Scribe) on Feb 09, 2014 at 02:55 UTC | |
by AnomalousMonk (Archbishop) on Feb 09, 2014 at 12:08 UTC | |
by choroba (Cardinal) on Feb 09, 2014 at 13:28 UTC | |
by puterboy (Scribe) on Feb 09, 2014 at 15:28 UTC |