$root = 'D:\projects\\'; @workspacefiles = split/\n/, `dir *.dsw /s /B`; s/\Q$root\E(.+)/$1/ for (@workspacefiles); #### foreach $dswfile ( @workspacefiles ) { $pathtodsw = "$root$dswfile"; $pathtodsw =~ s/(.*)\\.+?\.dsw/$1/; # Then I open the file and read the relevant data. }