1 package ExtUtils::Command;
8 use File::Path qw(rmtree);
10 use vars qw(@ISA @EXPORT $VERSION);
12 @EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f);
17 ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc.
21 perl -MExtUtils::Command -e cat files... > destination
22 perl -MExtUtils::Command -e mv source... destination
23 perl -MExtUtils::Command -e cp source... destination
24 perl -MExtUtils::Command -e touch files...
25 perl -MExtUtils::Command -e rm_f file...
26 perl -MExtUtils::Command -e rm_rf directories...
27 perl -MExtUtils::Command -e mkpath directories...
28 perl -MExtUtils::Command -e eqtime source destination
29 perl -MExtUtils::Command -e chmod mode files...
30 perl -MExtUtils::Command -e test_f file
34 The module is used in the Win32 port to replace common UNIX commands.
35 Most commands are wrappers on generic modules File::Path and File::Basename.
43 @ARGV = map(/[\*\?]/ ? glob($_) : $_,@ARGV);
48 Concatenates all files mentioned on command line to STDOUT.
60 Sets modified time of dst to that of src
66 my ($src,$dst) = @ARGV;
69 utime((stat($src))[8,9],$dst);
74 Removes directories - recursively (even if readonly)
80 rmtree([grep -e $_,expand_wildcards()],0,0);
85 Removes files (even if readonly)
91 foreach (expand_wildcards())
97 carp "Cannot delete $_:$!";
101 =item touch files ...
103 Makes files exist, with current timestamp
113 my $file = shift(@ARGV);
114 open(FILE,">>$file") || die "Cannot write $file:$!";
120 =item mv source... destination
122 Moves source to destination.
123 Multiple sources are allowed if destination is an existing directory.
129 my $dst = pop(@ARGV);
131 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
134 my $src = shift(@ARGV);
139 =item cp source... destination
141 Copies source to destination.
142 Multiple sources are allowed if destination is an existing directory.
148 my $dst = pop(@ARGV);
150 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
153 my $src = shift(@ARGV);
158 =item chmod mode files...
160 Sets UNIX like permissions 'mode' on all the files.
166 my $mode = shift(@ARGV);
167 chmod($mode,expand_wildcards()) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
170 =item mkpath directory...
172 Creates directory, including any parent directories.
178 File::Path::mkpath([expand_wildcards()],1,0777);
183 Tests if a file exists
189 exit !-f shift(@ARGV);
200 Should probably be Auto/Self loaded.
204 ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32
208 Nick Ing-Simmons <F<nick@ni-s.u-net.com>>.