Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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">

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477142]
help
Chatterbox?
[LanX]: when did you move to Utrecht, you used to live in a windmill on a dyke walking around in wooden shoes. ..
[LanX]: ... did you lie to me? OO
erix wouldn't mind a nice old windmill to live in... Mueller/Miller/ Molenaar
LanX likes Swedish clogs

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2017-12-15 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (439 votes). Check out past polls.

    Notices?