Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Insert into string

by gopalr (Priest)
on Jul 22, 2005 at 08:34 UTC ( #477142=note: print w/ replies, xml ) Need Help??


in reply to Insert into string

Hello

You did 2 mistakes in ur coding. That is:

1. Your variable name is wrong. $strFile variable not contains any text. so do change it to $src.

2. ? missing in <record (.*)>

$src ='<?xml version="1.0" encoding="UTF-8"?><record name="rightnav" t +ype="content"><item name="RHS_Image"><value>/me/accounts/include/imag +es/accounts_RHS.jpg</value> </item> <item name="RHS_Navigation">'; $new_tag ='<item name="abcd"><value>'; if($src =~ /<record (.*?)>/igm){ $src=~ s/$&/$&$new_tag/i; } print "\n$src";

Output:

<?xml version="1.0" encoding="UTF-8"?><record name="rightnav" type="co +ntent"><it em name="abcd"><value><item name="RHS_Image"><value>/me/accounts/inclu +de/images/ accounts_RHS.jpg</value> </item> <item name="RHS_Navigation">


Comment on Re: Insert into string
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-07-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls