Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2016-08-27 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (387 votes). Check out past polls.