Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Executing script in normal/daemon mode and adding start/stop capabilityby ELISHEVA (Prior) |
on Oct 07, 2009 at 11:12 UTC ( [id://799689]=note: print w/replies, xml ) | Need Help?? |
To avoid code duplication, use a subroutine. Also you will find your code easier to read an debug if you use consistent indenting. The block of code controlled by a flow-of-control statement should always be indented inside the flow of control statement. It is also a good idea to be consistent in your choice of cuddled and uncuddled curly braces. A third bit of advice, $@ can sometimes be set to undef even if there is an error. Even so, eval will always return undefined when there is an error. A much better way to check for errors is the incantation:
With a subroutine and the above eval incantation, your code (indenting revised):
becomes
Best, beth Update Added comments about eval handling.
In Section
Seekers of Perl Wisdom
|
|