ub del{ my $filename="test.txt"; my $template_data = "new/".$filename; undef $/; # Slurp mode open(DATA_IN, "$template_data") || print "Can't open output file1: $template_data\n"; #binmode DATA_IN; $_ = ; while(/<\?--([^-]*)-([^-]*)-->(.*?)<\/\?--([^-]*)-([^-]*)-->/sg){ $a=$1;$b=$2;$c=$3;$d=$4;$e=$5; if ($a eq $location){ if($b eq $obj_name) { #Code should be here, and it's where I am having problems... } } $list=$list. "$c\n"; } close DATA_IN; open( DATA_OUT, ">test.new" ) or die "$!\n"; print DATA_OUT "$list\n"; close DATA_OUT;