1 package ExtUtils::Command;
7 use File::Path qw(rmtree);
9 use vars qw(@ISA @EXPORT $VERSION);
11 @EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f);
16 ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc.
20 perl -MExtUtils::command -e cat files... > destination
21 perl -MExtUtils::command -e mv source... destination
22 perl -MExtUtils::command -e cp source... destination
23 perl -MExtUtils::command -e touch files...
24 perl -MExtUtils::command -e rm_f file...
25 perl -MExtUtils::command -e rm_rf directories...
26 perl -MExtUtils::command -e mkpath directories...
27 perl -MExtUtils::command -e eqtime source destination
28 perl -MExtUtils::command -e chmod mode files...
29 perl -MExtUtils::command -e test_f file
33 The module is used in Win32 port to replace common UNIX commands.
34 Most commands are wrapers on generic modules File::Path and File::Basename.
40 Concatenates all files menthion on command line to STDOUT.
51 Sets modified time of dst to that of src
57 my ($src,$dst) = @ARGV;
60 utime((stat($src))[8,9],$dst);
65 Removes directories - recursively (even if readonly)
76 Removes files (even if readonly)
86 next if (-f $_ and unlink($_));
87 die "Cannot delete $_:$!";
93 Makes files exist, with current timestamp
101 my $file = shift(@ARGV);
102 open(FILE,">>$file") || die "Cannot write $file:$!";
107 =item mv source... destination
109 Moves source to destination.
110 Multiple sources are allowed if destination is an existing directory.
116 my $dst = pop(@ARGV);
121 my $src = shift(@ARGV);
122 my $leaf = basename($src);
123 move($src,"$dst/$leaf"); # fixme
128 my $src = shift(@ARGV);
129 move($src,$dst) || die "Cannot move $src $dst:$!";
133 =item cp source... destination
135 Copies source to destination.
136 Multiple sources are allowed if destination is an existing directory.
142 my $dst = pop(@ARGV);
147 my $src = shift(@ARGV);
148 my $leaf = basename($src);
149 copy($src,"$dst/$leaf"); # fixme
158 =item chmod mode files...
160 Sets UNIX like permissions 'mode' on all the files.
166 chmod(@ARGV) || die "Cannot chmod ".join(' ',@ARGV).":$!";
169 =item mkpath directory...
171 Creates directory, including any parent directories.
177 File::Path::mkpath([@ARGV],1,0777);
182 Tests if a file exists
188 exit !-f shift(@ARGV);
198 eqtime does not work right on Win32 due to problems with utime() built-in
201 Should probably be Auto/Self loaded.
205 ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32
209 Nick Ing-Simmons <F<nick@ni-s.u-net.com>>.