in reply to Re: Yet another perl-rename tool
in thread Yet another perl-rename tool
#!/usr/bin/perl use strict; use warnings; my $f = shift; if ($f =~ m[^s/]) { $f = eval "sub { $f }"; } else { my $re = qr/$f/; my $to = shift; $f = eval "sub { s/\$re/$to/ }"; } for (@ARGV) { my $o = $_; $f->(); if ($o ne $_) { if ( ! -e $o ) { print "rename $o, $_\n"; rename $o, $_; } else { print "can't rename : $o exists\n" } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Yet another perl-rename tool
by chb (Deacon) on Feb 25, 2009 at 14:58 UTC | |
by parv (Parson) on Feb 26, 2009 at 02:53 UTC |