[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python or Perl for a Debian maintainance project?



On Thu, Feb 19, 2004 at 12:10:18PM -0500, Joey Hess wrote:
> > Now try the same thing in Perl.
> 
> $f=create_a_file($name);
> eval {
> 	do_something_insanely_complicated($f);
> };
> if ($@) {
> 	unlink $name;
> 	die $@;
> }

<rant>
ACK!  What's with all the $@ stuff?!  This is my biggest pet peeve with
Perl.  Syntactic sugar.  Perhaps to a Perl programmer, this makes sense.
Because I have a background in shell programming, I interpret "$@" to
mean "arguments $1...$N".  Obviously wrong.

[Looks up perl syntactic sugar reference manualorama 'perldoc perlcheat']

    "$@    eval error"

Ick.  Almost as bad as $_.
</rant>

> Of course this is rare, since Perl code that is ill-behaved enough to
> throw an exception is rare, so it's more standard Perl idiom to write:
> 
> do_something_insanely_complicated(create_a_file($name)) or unlink($name);

OK.  This makes sense.  No syntactic sugar involved.  Clean, precise.
If all Perl were like this, I'd be much happier using it.

-- 
Chad Walstrom <chewie@wookimus.net>           http://www.wookimus.net/
           assert(expired(knowledge)); /* core dump */

Attachment: signature.asc
Description: Digital signature


Reply to: