[ABE.pm] Re: automating FTP in Perl

Phil Lawrence phil at five-lawrences.com
Wed Dec 15 09:49:49 CST 2004


On Dec 10, 2004, at 12:56, Ricardo SIGNES wrote:
> ... it's very common to hear "keep flow control on the
> left."  die is flow control, so one would normally write:
>
> 	die "error message"
> 		unless $object->can_do_something_important;
>
> Once you need multiple things to happen, flip it and use a real block.
>
> 	unless ($obj->can_do) {
> 		log_error;
> 		die "message";
> 	}

Nice...  I like that "flow control to the left" bit.

>
> Also, don't use die without an error message.  Even a single word will
> make life easier later.

In prod code, yes...  but when writing new code, die()'s habit of 
spitting out line numbers when not given a \n -terminated argument is 
handy on its own.

prl



More information about the ABE-pm mailing list