#!/usr/bin/perl -wl use strict; my $root = '/mydirectory/directory/'; my @files = qw( /mydirectory/directory/test/z2.htm /mydirectory/directory/other/testhere.htm /mydirectory/directory/test/dir/z6.htm ); foreach my $file (@files) { print substr $file, length $root; } __END__ Prints: test/z2.htm other/testhere.htm test/dir/z6.htm