Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
<?--1-Stock3of1--> <b>This is option Stock 3 of 1</b> </?--1-Stock3of1-->
<?--1-News1--> <b>This is option News 1 of 1</b> </?--1-News1--> <?--1-Weather2of1--> <b>This is option Weather 2 of 1</b> </?--1-Weather2of1--> <?--1-Stock3of1--> <b>This is option Stock 3 of 1</b> </?--1-Stock3of1--> <?--2-Second1of2--> <b>Option Second 1 of 2</b> </?--2-Second1of2--> <?--3-Third1of3--> <b>Option Third 1 of 3</b> </?--3-Third1of3-->
sub 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; $_ = <DATA_IN>; while(/<\?--([^-]*)-([^-]*)-->(.*?)<\/\?--([^-]*)-([^-]*)-->/sg){ $a=$1;$b=$2;$c=$3;$d=$4;$e=$5; if ($a eq $location){ if($b eq $obj_name) { $c=$page; $_=~s/<\?--([^-]*)-([^-]*)-->(.*?)<\/\? +--([^-]*)-([^-]*)-->//sg; } } $list=$list. "<?--$a-$b-->$c</?--$d-$e-->\n";} close DATA_IN; open( DATA_OUT, ">new/test.txt" ) or die + "$!\n"; print DATA_OUT "$list\n"; close DATA_OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression Help Help
by graff (Chancellor) on Oct 23, 2002 at 01:55 UTC | |
|
Re: Regular Expression Help Help
by Enlil (Parson) on Oct 22, 2002 at 23:42 UTC |