in reply to Re: Re: A C-like brain in a Perl-like world
in thread A C-like brain in a Perl-like world

Forcing a BLOCK rather than an instruction after an if is because of a simple reason: the "dangling else". It is not apparent in which way if $condition if $more_condition do_something() else do_other() is to be disambiguated; many tradiditional languages arbitrarily choose to bind the else branch to the closest if, but that's not readily apparent from looking at the code - and if you want to bind the else of the first if, you still have to use a BLOCK around the second.

So Perl forces you to use BLOCKs for clarity, but lets you append an if clause as a statement modifier for when you want brevity: do_something if $condition;.

<CODE> has more functions than formatting. For pseudocode, you can use the regular <tt></tt> HTML tags.

  • Comment on Re^3: A C-like brain in a Perl-like world