Michele Dondi skribis 2004-06-22 18:24 (+0200):
> rename -v => 1, $orig, $new;
Any specific reason for the minus there? Perl's not a shell (yet).
> rename.SWITCHES{-v} = sub {
> my ($o, $n) = @_;
> print "renaming `$o' to `$n'\n";
> }
I think just using named arguments would be better and much easier.
sub rename ($old, $new, +$verbose) {
say "Renaming '$old' to '$new'" if $verbose;
...;
}
rename verbose => 1, $oldthingy, $newthingy;
rename $oldthingy, $newthingy, :verbose; # alternative, more
# switch-like pair constructor
Juerd