my @the_files = ('apple', 'pear', 'food'); my %image_hash = ('a'=>'z', 'o'=>'u', ); foreach my $file (@the_files) { my $newFile = $file; foreach my $key (keys %image_hash) { my $replaceVal = %image_hash->{$key}; $newFile =~ s/$key/$replaceVal/g; } print "move $file, $newFile or die 'Bummer!' \n"; }