summaryrefslogtreecommitdiff
path: root/eg/rename
blob: 1708d35def64690a28229055e582863f7fc27916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if ($#ARGV < 0) {
    @ARGV = <stdin>;
    chop(@ARGV);
}
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}