Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Insert into string

by gopalr (Priest)
on Jul 22, 2005 at 08:34 UTC ( [id://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">

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found