undef $/; #slurps entire file while (){ @my_data=split m{(?:"D:/Program Files/)}; #splits according to the filepath without removing it }