in reply to Renaming file without forward slash

This will chop off the .txt extension on all the files in @file:

... foreach $word (@file) { if ((my $new = $word) =~ s/\.txt$//) { rename($word, $new) or die "unable to rename $word to $new: $!\n"; } }
Is this what you're looking for?

Replies are listed 'Best First'.
Re^2: Renaming file without forward slash
by Ball_22_11 (Initiate) on Feb 25, 2008 at 04:20 UTC
    When I run it it takes away the .txt extension but I'm trying to also take out the rest of the path to the file and only have the filename