use strict; use warnings; my $paths = < length($a)} <$file_paths>; print join "\n", split ('\|', $references), ''; for my $test ( "/unix/path/to/folder/is/herewitha_file.txt", "/unix/path/to/folder/is/herea_file.txt" ) { $test =~ /($references)/; print "$1\n"; }