Sigue el código completo:
pp2@europa:~$ sed -ne '32,71p' `which rename` | cat -n 1 use strict; 2 3 use Getopt::Long; 4 Getopt::Long::Configure('bundling'); 5 6 my ($verbose, $no_act, $force, $op); 7 8 die "Usage: rename [-v] [-n] [-f] perlexpr [filenames]\n" 9 unless GetOptions( 10 'v|verbose' => \$verbose, 11 'n|no-act' => \$no_act, 12 'f|force' => \$force, 13 ) and $op = shift; 14 15 $verbose++ if $no_act; 16 17 if (!@ARGV) { 18 print "reading filenames from STDIN\n" if $verbose; 19 @ARGV = <STDIN>; 20 chop(@ARGV); 21 } 22 23 for (@ARGV) { 24 my $was = $_; 25 eval $op; 26 die $@ if $@; 27 next if $was eq $_; # ignore quietly 28 if (-e $_ and !$force) 29 { 30 warn "$was not renamed: $_ already exists\n"; 31 } 32 elsif ($no_act or rename $was, $_) 33 { 34 print "$was renamed as $_\n" if $verbose; 35 } 36 else 37 { 38 warn "Can't rename $was $_: $!\n"; 39 } 40 }
Casiano Rodríguez León