[Israel.pm] Golf

Madani, Srikanth, VF-DE Srikanth.Madani at vodafone.com
Thu Nov 3 00:22:58 PST 2005


Thanks Dov, Yosef, Mikhael and Gaal!
 
> my $Done = (&what(0) or "etwas");

works pefectly. I prefer not using the '&' and using '||' instead of
'or' and dispensing with the braces; the result:

	my $Done = what(0) || "etwas";

works too.

I wasn't aware this was possible. It is explained in this snip from man
perlop:

     The || and && operators differ from C's in that, rather than
     returning 0 or 1, they return the last value evaluated.

Cheers,
Srikanth Madani

ps: Mikhael Goikhman wrote:

>  my $answer = ask("yourself") // ask("friend") // ask("mother");
>  $answer //= ask("mailing list") // 42;

what_is_the_question(42);




More information about the Perl mailing list