package Psh
::Builtins
::Rename
;
=item * C<rename> [-i] perlcode [files]
"rename" provides the filename in $_ to perlcode
and renames according to the new value of $_ modified
Originally written by Larry Wall
if ($Psh::interactive
&& $op eq '-i') {
$op= Psh
::Parser
::unquote
($op);
@words = Psh
::Parser
::glob_expansion
(\
@words);
@words = map { Psh
::Parser
::unquote
($_)} @words;
foreach my $file (@words) {
print STDERR
"$Psh::bin: $file: $!\n";
$Psh::PerlEval
::lastscalar
=$was;
Psh
::PerlEval
::protected_eval
($op);
my $now= $Psh::PerlEval
::lastscalar
;
if ($inspect && -e
$now) {
next unless Psh
::Util
::prompt
("yn","remove $now?") eq 'y';
print STDERR
"$_ exists. $was not renamed\n";
if (CORE
::rename($was,$now)) {
print STDERR
"$Psh::bin: can't rename $was to $now: $!\n";
return ($count>0,$count);