News for hackers. Stuff that matters.
Re:CoffeeScript -- You Are Totally Gonna Hate It by Andys on Saturday July 17, 2010 @07:46PM (#1524883)
Not really: for example, if/else statements are not expressions whose results can be assigned to a variable like in Ruby.
Re:CoffeeScript -- You Are Totally Gonna Hate It by draegtun on Sunday July 18, 2010 @11:08AM (#1525873)
This thread is about needing an implicit return. So my "ditto" is 100% correct!

But you are quite right that Perl if/else are statements and not expressions. Instead you can use the ternary operator:

    my $value = $cond == 1 ? 'true' : 'false';
And because of ditto for Perl you can also do following:

    my $value = do { if ($cond == 1) { 'true' } else { 'false' } };