thakares has asked for the wisdom of the Perl Monks concerning the following question:
Please go through following code.
#! /usr/bin/env perl use strict; use warnings; use 5.0080; my $html =<<'HTML'; <div> <p>Code</p> <?perl print "<b>Hello World</b>"; ?> </div> HTML # trial 1 $html =~ s/\<\?perl(.*?)\?\>/$1/gisee; # trial 2 $html =~ s/\<\?perl(.*?)\?\>/(sub{$1})->()/gisee; print $html;
This prints the output as follows:(trial #1 or #2)
<b>Hello World</b><div> <p>Code</p> 1 </div>
But I want as follows:
<div> <p>Code</p> <b>Hello World</b> </div>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Eval in RegEx ...
by hdb (Monsignor) on Dec 06, 2013 at 15:22 UTC | |
by thakares (Acolyte) on Dec 06, 2013 at 15:49 UTC | |
by ww (Archbishop) on Dec 07, 2013 at 12:48 UTC | |
|
Re: Eval in RegEx ...
by kennethk (Abbot) on Dec 06, 2013 at 15:24 UTC | |
by thakares (Acolyte) on Dec 06, 2013 at 16:05 UTC | |
by kennethk (Abbot) on Dec 06, 2013 at 18:09 UTC | |
by thakares (Acolyte) on Dec 07, 2013 at 06:35 UTC | |
|
Re: Eval in RegEx ...
by taint (Chaplain) on Dec 06, 2013 at 13:54 UTC | |
by thakares (Acolyte) on Dec 06, 2013 at 15:51 UTC | |
by taint (Chaplain) on Dec 06, 2013 at 16:04 UTC | |
by thakares (Acolyte) on Dec 06, 2013 at 16:11 UTC | |
by taint (Chaplain) on Dec 06, 2013 at 16:18 UTC |