in reply to Re^2: Code blocks with ternary operator or trailing conditionals
in thread Code blocks with ternary operator or trailing conditionals
... a way to 'do' it without it...
I wouldn't say this is a better way (in fact, as kcott has pointed out below, if { ... } else { ... } syntax is better for what you seem to want than this or a do block), but it's a way:
c:\@Work\Perl\monks>perl -wMstrict -le "my $x = 42; ;; sub { print qq{Hello }; print qq{world!}; }->() if 7 < $x; ;; 43 > $x ? sub { print qq{Yes, }; print qq{it is!}; }->() : sub { print qq{No, }; print qq{it is not!}; }->() ; " Hello world! Yes, it is!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Code blocks with ternary operator or trailing conditionals
by choroba (Cardinal) on Feb 09, 2014 at 13:28 UTC | |
|
Re^4: Code blocks with ternary operator or trailing conditionals
by puterboy (Scribe) on Feb 09, 2014 at 15:28 UTC |