Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Manipulating a string in a tagged file

by Samy_rio (Vicar)
on Mar 12, 2007 at 11:00 UTC ( #604315=note: print w/replies, xml ) Need Help??


in reply to Manipulating a string in a tagged file

Hi rsriram, try like this,

use strict; use warnings; my $str = '<tag1>Complete</tag1><tag2>3386</tag2><tag3>77844</tag3><ta +g4>11</tag4><tag5>30</tag5><tag6>4.7</tag6>'; if($str =~ /<tag1>Complete<\/tag1>/i) { $str =~ s/<tag6>(.+?)<\/tag6>/"<tag6>".( $1 * 100 )."<\/tag6>"/ei; } print $str;

Updated

Typo error in your replacement statement. Use 'e' option modifier for execute the statement in the replacement part.

See the documentation for further clarification perlre

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://604315]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2016-12-04 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (66 votes). Check out past polls.