#!/usr/bin/env perl -l use strict; use warnings; use autodie; use File::Spec; my ($infile, $outfile) = qw{pm_1189607_input pm_1189607_output}; my %new_path_for = ( 'old/path/to/some/' => 'new/path/to/some/', 'another/old/path/to/some/' => 'another/new/path/to/some/', 'one/more/old/path/to/some/' => 'one/more/new/path/to/some/', ); { open my $in_fh, '<', $infile; open my $out_fh, '>', $outfile; while (<$in_fh>) { chomp; my ($vol, $dirs, $file) = File::Spec::->splitpath($_); $dirs = $new_path_for{$dirs} if exists $new_path_for{$dirs}; print $out_fh File::Spec::->catpath($vol, $dirs, $file); } }