my $filename="test.txt"; my $template_data = "unsecure/".$filename; open(DATA_IN, ">>$template_data") || print "Can't open output file1: $template_data\n"; #binmode DATA_IN; undef $/; $_ = ; if($_=~/<\?--([^-]*)-([^-]*)-->(.*?)<\/\?--\1-\2-->/sg) { } #### Location 2 Location 2 Location 2 Location 2 Location 2