--1-News1-->
This is option News 1 of 1
?--1-News1-->
--1-Weather2of1-->
This is option Weather 2 of 1
?--1-Weather2of1-->
--1-Stock3of1-->
This is option Stock 3 of 1
?--1-Stock3of1-->
--2-Second1of2-->
Option Second 1 of 2
?--2-Second1of2-->
--3-Third1of3-->
Option Third 1 of 3
?--3-Third1of3-->
####
use strict;
use CGI qw(:header);
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
print "content-type: text/html\n\n";
#&getdata(%in);
&getdata;
#$location = $in{'location'};
#$obj_name = $in{'obj_name'};
#$page = $in{'page'};
#The value on these variable are hard coded for testing
#my $location=param('location');
$location="1";
#my $obj_name=param('obj_name');
$obj_name="News1";
$page="Testing New Content for Object ONE TWO";
my $filename="test.txt";
my $template_data = "unsecure/".$filename;
undef $/; # Slurp mode
open(DATA_IN, "$template_data") || print "Can't open output file1: $template_data\n";
#binmode DATA_IN;
$_ = ;
#close DATA_IN;
while(/<\?--([^-]*)-([^-]*)-->(.*?)<\/\?--([^-]*)-([^-]*)-->/sg){
#--1-News1-->
#This is option News 1 of 1
#?--1-News1-->
$a=$1;$b=$2;$c=$3;$d=$4;$e=$5;
if ($a eq $location){
if($b eq $obj_name) {
#$c=~s/$c/$page/ig;
$c=$page;
open( DATA_OUT, ">/unsecure/test.new" ) or die "$!\n";
print DATA_OUT "--$a-$b-->\n";
print DATA_OUT "$c\n";
print DATA_OUT "?--$d-$e-->\n";
}
}
}
#print DATA_OUT;
close DATA_OUT;
close DATA_IN;
#print "content-type: text/html\n\n";
print " EDITOR
\n";
print "
";
print "You're about to change location: $location";
print "
\n";
print "Viewing object name: $obj_name";
print "
\n";
print "
\n";
print "$page";
print "
";;
print "
";
print "\n";