Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: First Unix Admin Script - Request for Constructive Critisism

by tall_man (Parson)
on Feb 09, 2003 at 01:08 UTC ( [id://233803] : note . print w/replies, xml ) Need Help??


in reply to Re: Re: First Unix Admin Script - Request for Constructive Critisism
in thread First Unix Admin Script - Request for Constructive Critisism

You ask about redirecting STDOUT and STDERR for system calls given as lists. A good way to do this is with the module IPC::Run.
use IPC::Run qw( run ) ; run \@cmd, \$in, \$out, \$err;

One idea you might be able to use for parameterizing your error messages for various commands would be to pass in a hash reference containing explanatory messages indexed by return codes. Also see perlvar for how you can use the variable $! to obtain error message strings after a failed system call.

Finally, the reason spelled-out file handles are considered "bad style" compared to IO::File is that they create global names, which might conflict with other modules. IO::File uses unique private symbols instead.