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 Win32 port to replace common UNIX commands.
35 Most commands are wrapers 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
112 my $file = shift(@ARGV);
113 open(FILE,">>$file") || die "Cannot write $file:$!";
118 =item mv source... destination
120 Moves source to destination.
121 Multiple sources are allowed if destination is an existing directory.
127 my $dst = pop(@ARGV);
129 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
132 my $src = shift(@ARGV);
137 =item cp source... destination
139 Copies source to destination.
140 Multiple sources are allowed if destination is an existing directory.
146 my $dst = pop(@ARGV);
148 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
151 my $src = shift(@ARGV);
156 =item chmod mode files...
158 Sets UNIX like permissions 'mode' on all the files.
164 my $mode = shift(@ARGV);
165 chmod($mode,expand_wildcards()) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
168 =item mkpath directory...
170 Creates directory, including any parent directories.
176 File::Path::mkpath([expand_wildcards()],1,0777);
181 Tests if a file exists
187 exit !-f shift(@ARGV);
197 Should probably be Auto/Self loaded.
201 ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32
205 Nick Ing-Simmons <F<nick@ni-s.u-net.com>>.