1 ##--------------------------------------------------------------------------##
3 ## $Id: Util.pm,v 1.5 2002/09/13 07:24:18 ehood Exp $
6 ##--------------------------------------------------------------------------##
7 ## Copyright (C) 2002 Earl Hood <earl@earlhood.com>
9 ## This program is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 2 of the License, or
12 ## (at your option) any later version.
14 ## This program is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License
20 ## along with this program; if not, write to the Free Software
21 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 ##--------------------------------------------------------------------------##
39 ##--------------------------------------------------------------------------##
46 ##--------------------------------------------------------------------------##
49 print "@_\n" if $ECHO_CMDS || $ECHO_ONLY;
51 return 0; # bogus ok exit status
58 print "chdir $dir\n" if $ECHO_CMDS || $ECHO_ONLY;
66 print "@_\n" if $ECHO_CMDS || $ECHO_ONLY;
69 die qq/system @_ failed: $?\n/ if $wait;
76 print "mkdir $dir\n" if $ECHO_CMDS || $ECHO_ONLY;
90 print "@_\n" if $ECHO_CMDS || $ECHO_ONLY;
95 die qq/exec @_ failed: $?\n/;
103 Pod
::Usage
::pod2usage
(-verbose
=> $verbose);
105 my $pager = $ENV{'PAGER'} || 'more';
107 my $fh = (-t STDOUT
&& open(PAGER
, "|$pager")) ? \
*PAGER
: \
*STDOUT
;
108 Pod
::Usage
::pod2usage
(-verbose
=> $verbose,
113 ##--------------------------------------------------------------------------##
119 MHArc::Util - General utilities for mail archiving system.
127 This module contains a collection of utility routines.
131 The following module variables can be set to affect the behavior
132 of the utility routines:
138 If set to a true value, any routines that execute shell commands,
139 or external programs, will print the command to be executed to the
142 The default value for C<$ECHO_CMDS> is 0.
146 If set to a true value, any routines that execute shell commands,
147 will only print the command to be executed to the default filehandle
148 if C<$ECHO_CMDS> is true. The command itself will not be
151 The default value for C<$ECHO_ONLY> is 0.
157 By default, no routines are exported into the calling namespace.
158 Routines in this module can be imported by explicitly listing the
159 routines to import in the C<use> declaration:
161 use MHArc::Util qw( run_prg );
163 The following routines are availale:
167 =item C<ch_dir($dir)>
169 Change the current working directory.
173 Execute external program. The return value is the wait(2) status
174 of the program invoked.
176 =item C<mk_dir($dir, $mask)>
178 Create specified directory. C<$mask> is optional, and if
179 not specified, will default to C<0777>.
181 =item C<run_prg(LIST)>
183 Execute external program and terminate process if program returns
186 =item C<usage($verbosity)>
188 Display usage information of program based upon embedded POD.
189 The C<$verbosity> argument has the same meaning as the C<-verbose>
190 option to C<Pod::Usage::pod2usage>.
196 C<$Id: Util.pm,v 1.5 2002/09/13 07:24:18 ehood Exp $>
200 Earl Hood, earl@earlhood.com
202 This module is part of the mharc archiving system and comes with
203 ABSOLUTELY NO WARRANTY and may be copied only under the terms of
204 the GNU General Public License, which may be found in the mharc