On Tue, Jul 14, 2009 at 07:01, Shawn H. Corey<shawnhco...@gmail.com> wrote: > On Mon, 2009-07-13 at 23:49 -0400, Chas. Owens wrote: >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> sub timeout { >> my ($wait, $code, $timedout, $error) = (@_, >> sub { warn $@ }, sub { die $@ }); > > # I'm just too paranoid to let this pass > my ( $wait, $code ) = @_; > my ( $timeout, $error ) = ( sub { warn $@ }, sub { die $@ } ); snip
You just removed a major feature of the code. Do you want to explain why your paranoia has lead you to remove the ability to override the default $timedout and $error handlers? I could understand if your paranoia lead you to check to make sure the types were right: use Scalar::Util qw/looks_like_number reftype/; ... my ($wait, $code, $timedout, $error) = (@_, sub { warn $@ }, sub { die $@ }); my $errors = 0; if (@_ > 4) { carp "too many arguments"; $errors++; elsif (@_ < 2) { carp "too few arguments"; $errors++; } unless (looks_like_number $wait) { carp "the wait argument must be an integer"; $errors++; } unless (reftype $code eq 'CODE') { carp "the code argument must be a code reference"; $errors++; } unless (reftype $timedout eq 'CODE') { carp "the timedout argument must be a code reference"; $errors++; } unless (reftype $error eq 'CODE') { carp "the error argument must be a code reference"; $errors++; } croak "too many errors ($errors) to continue" if $errors; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/