Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How to replace only the first <p> with <con><p> and last </p> with#!/usr/bin/perl use strict; use warnings; while(<DATA>){ $_ =~ s/<p>/<con><p>/g; $_ =~ s/<\/p>/<\/p><\/con>/g; print $_; } __DATA__ <p>This is param1</p> <p>This is second para</p> <p>this is param3</p>
tag is substituted.</p></con><code> <br/> Now all the <code><p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search and replace
by keszler (Priest) on Nov 04, 2009 at 16:05 UTC | |
|
Re: search and replace
by bichonfrise74 (Vicar) on Nov 04, 2009 at 17:46 UTC | |
by Anonymous Monk on Nov 05, 2009 at 05:07 UTC | |
by Your Mother (Archbishop) on Nov 05, 2009 at 05:16 UTC | |
by Anonymous Monk on Nov 05, 2009 at 06:13 UTC | |
by Anonymous Monk on Nov 05, 2009 at 16:09 UTC | |
|