in reply to Re^2: How to rename the files its directory structure using perl?
in thread How to rename the files its directory structure using perl?

ok changed my mind too run this

sub runDir { my $prefix = shift @_; print '*'.$prefix,"\n"; my $dir = shift @_; print "**$dir*","\n"; opendir(DIR, $dir) or die $!; my @entries = readdir(DIR); # print @entries,"\n"; close(DIR); foreach my $file (@entries) { next if ($file =~ /^\.+$/); if ( -d $dir . '/' . $file) { print '***down runDir -- '.$prefix . $file . '_'.','. $dir + . '/' . $file."\n"; runDir($prefix . $file . '_', $dir . '/' . $file); print '***up runDir -- '.$prefix . $file . '_'.','. $dir +. '/' . $file."\n"; } elsif ( ( -f $dir . '/' . $file ) && ( $file =~ /\.config$/ +) && ($file !~ /^$prefix/)) { my $suffix = $file; $suffix =~ s/^(\S+)-.+\.config$/$1.config/; print '****rename '.$dir . '/' . $file.','. $dir . '/' . $ +prefix . $suffix ."\n"; # rename $dir . '/' . $file, $dir . '/' . $prefix . $suffi +x ; } } }
dayum i hate double quotes a lot.

Replies are listed 'Best First'.
Re^4: How to rename the files its directory structure using perl?
by finddata (Sexton) on Mar 16, 2017 at 04:16 UTC
    But the above code change we cant get the expected output.you just remove the prototype .I couldnt see any other changes which you have done.

      the manner in which the ***up/***down/****rename lines are printed has also changed so you might understand the lines better.