1 package ExtUtils::Command;
10 use File::Path qw(rmtree);
12 our(@ISA, @EXPORT, $VERSION);
14 @EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f);
19 ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc.
23 perl -MExtUtils::Command -e cat files... > destination
24 perl -MExtUtils::Command -e mv source... destination
25 perl -MExtUtils::Command -e cp source... destination
26 perl -MExtUtils::Command -e touch files...
27 perl -MExtUtils::Command -e rm_f file...
28 perl -MExtUtils::Command -e rm_rf directories...
29 perl -MExtUtils::Command -e mkpath directories...
30 perl -MExtUtils::Command -e eqtime source destination
31 perl -MExtUtils::Command -e chmod mode files...
32 perl -MExtUtils::Command -e test_f file
36 The module is used in the Win32 port to replace common UNIX commands.
37 Most commands are wrappers on generic modules File::Path and File::Basename.
45 @ARGV = map(/[\*\?]/ ? glob($_) : $_,@ARGV);
50 Concatenates all files mentioned on command line to STDOUT.
62 Sets modified time of dst to that of src
68 my ($src,$dst) = @ARGV;
71 utime((stat($src))[8,9],$dst);
76 Removes directories - recursively (even if readonly)
82 rmtree([grep -e $_,expand_wildcards()],0,0);
87 Removes files (even if readonly)
93 foreach (expand_wildcards())
99 carp "Cannot delete $_:$!";
103 =item touch files ...
105 Makes files exist, with current timestamp
115 my $file = shift(@ARGV);
116 open(FILE,">>$file") || die "Cannot write $file:$!";
122 =item mv source... destination
124 Moves source to destination.
125 Multiple sources are allowed if destination is an existing directory.
131 my $dst = pop(@ARGV);
133 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
136 my $src = shift(@ARGV);
141 =item cp source... destination
143 Copies source to destination.
144 Multiple sources are allowed if destination is an existing directory.
150 my $dst = pop(@ARGV);
152 croak("Too many arguments") if (@ARGV > 1 && ! -d $dst);
155 my $src = shift(@ARGV);
160 =item chmod mode files...
162 Sets UNIX like permissions 'mode' on all the files.
168 my $mode = shift(@ARGV);
169 chmod($mode,expand_wildcards()) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
172 =item mkpath directory...
174 Creates directory, including any parent directories.
180 File::Path::mkpath([expand_wildcards()],1,0777);
185 Tests if a file exists
191 exit !-f shift(@ARGV);
202 Should probably be Auto/Self loaded.
206 ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32
210 Nick Ing-Simmons <F<nick@ni-s.u-net.com>>.