in reply to Re: a simple exercise in readability
in thread a simple exercise in readability

# Command-line (my $x = shift) or die $syntax; (my $y = shift) or die $syntax;

One small problem with this approach is that it does not allow zero as an input. You have to say something like:

die $syntax if ! defined (my $x = shift);

...which is a little more clumsy, since the important part ($x = shift) is way off to the side.

Replies are listed 'Best First'.
Re^3: a simple exercise in readability
by liverpole (Monsignor) on Jan 15, 2007 at 17:46 UTC
    Yes, good point.  Of course my solution is only intended for cases where one explicitly does NOT want the value of zero as valid input.

    As for the "little more clumsy":

    die $syntax if ! defined (my $x = shift);

    and assuming you needed to allow for zero valued input, I'd be inclined to go with the slightly pithier:

    defined(my $x = shift) or die $syntax;

    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/