in reply to Re^2: renaming files from a tab delimited list
in thread renaming files from a tab delimited list

For file operations: Path::Tiny

use strict; use warnings; use feature 'say'; use Path::Tiny qw/ path /; say qx# ls /tmp/*.txt #; my $dir = '/tmp/'; my $ext = '.txt'; my $regex = qr/$ext/; my @paths = path( $dir )->children( $regex ); for my $file ( @paths ) { my $name = path( $file )->basename( $regex ); my $newname = join '', reverse split '', $name; path( $file )->move( join '', $dir, $newname, $ext ); } say qx# ls /tmp/*.txt #; __END__
Output:
/tmp/bar.txt /tmp/foo.txt /tmp/oof.txt /tmp/rab.txt

Hope this helps!


The way forward always starts with a minimal test.