while(/<\?--([^-]*)-([^-]*)-->(.*?)<\/\?--([^-]*)-([^-]*)-->/sg){ # $a=$1;$b=$2;$c=$3;$d=$4;$e=$5; # drop all those a b c d's next if ($1 eq $location && $2 eq $obj_name); $list .= "$3\n"; }