use strict; my @thing; # open up the DATA filehandle and loop one line at a time while () { # look for first \ and capture everything until the next \ into $1 # discard everything (.*) but don't be greedy (?) # capture any alphanumeric (\w) that is followed by .cxx into $2 if (/\\([^\\]+).*?(\w+\.cxx)/) { # store $1 and $2 into a datastructure push @thing, [$1,$2]; } } for (@thing) { my ($dir,$file) = @$_; print "$dir\t$file\n"; } __DATA__ qzang.5 \nbsstools\i95\src\i95val.h@@\main\golden\2 \nbsstools\i95\src\i95val.cxx@@\main\golden\2 \nbsstools\rlp\src\rlpval.cxx@@\main\golden\3 \nbsstools\rlp\src\rlpval.h@@\main\golden\3 source file(s) -- 4 rajeevv.19 \nbsscallpmsg\acl\src@@\main\golden\4 \nbsscallpmsg\acl\src\aclpi.h@@\main\golden\1 \nbsscallpmsg\acl\src\aclpi.cxx@@\main\golden\1 \nbsssbs\appl\src@@\main\golden\4 \nbsssbs\appl\src\radiomeasurements.h@@\main\golden\1