if (my ($tmp_dir, $file) = $line =~ m%(.*)\\(.*)% ) { # do the rest of the stuff } else { warn "$line has incorrect format!\n"; }