use Cwd qw( abs_path ); my $full = abs_path($file_path); my ($dir, $file) = $full =~ /^(.*)\\(.*)/; # Wrong for C:\File my ($dir, $file) = $full =~ /^(.*\\)(.*)/; # Ugly for C:\Dir\File