use strict; my @pathandfile = qw(c:\dir1/dir2/file1.txt c:\dir1/dir3/file2); for (@pathandfile) { $_ =~ /(.*)(\\|\/)(.*)$/; print "PATH: $1 - FILE: $3\n"; }