One thing I see with your code is, that _set_Max_Questions() is called from two places. I would rather set $Max_Questions throughout the if blocks and afterwards (if the program is still alive) call _set_Max_Questions(). As an aside, this seems to be object oriented code - why do you use the form &_set_Max_Questions($self,...) instead of $self->_set_Max_Questions(...) ?
# First, handle the sensible default $Max_Questions = $Total_Questions unless defined $Max_Questions; # Now check for errors if($Max_Questions > $Total_Questions){ croak "Number of questions in $FileName exceeded"; $Max_Questions = $Total_Questions; }elsif($Max_Questions < 1){ croak "Must have at least one question in the test."; $Max_Questions = 1; } # Now we have a valid number of questions &_set_Max_Questions($self,$Max_Questions);
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
In reply to Re: Optimization of a piece of code(Is there a better way than this?)
by Corion
in thread Optimization of a piece of code(Is there a better way than this?)
by TStanley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |