in reply to Re^2: foreach loop - could it beeeeee!!
in thread foreach loop - could it beeeeee!!

If you're going to start arguments about "readability for newbies", then I'll chip in and simply state that a "?:" syntax construct should not be used for statements (in void context), but only for expressions. For statements you should be using if/else instead.
my $pick; if($choice_array[0]) eq 'correct') { $pick = 'aaa'; } else { pick = 'b +bb'; }

All IMHO, of course.

Finally, I must say that I think that all this "readability for newbies" is all a pile of nonsense. Just make it readable for yourself.

Replies are listed 'Best First'.
Re^4: foreach loop - could it beeeeee!!
by JadeNB (Chaplain) on Oct 11, 2009 at 20:40 UTC
    I must say that I think that all this "readability for newbies" is all a pile of nonsense. Just make it readable for yourself.
    For the record, what I said was “… for folks like me who can never remember precedence …”. I am no expert, to be sure, but I'm not entirely a newbie, either. :-)
      Well, the don't take it personally, then...

      I always find that these arguments about readability degenerate into an argument for readability for a hypothetical user. Usually this user is a newbie who, apparently, is clueless about Perl idioms. So the more more the code looks like other languages, such as Java, the better.

      Well, I don't buy it. The main reason why people use Perl instead of any other language, is because it makes it easier to do certain tasks than those other languages. Restricting yourself to a subset so those people coming from other languages can read it, is simply throwing away that advantage.

      So, let's say I was just one step ahead of you, then... :)