Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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?
[Discipulus]: Satura Lanx was a latin genre of show
[Discipulus]: coming from the meaning of 'mixed dish'
[Discipulus]: thanks hippo! the hat you passed me was brand new and clean, thanks
LanX OS builds on multitasking humor ...
[LanX]: ... next release comes with even more random puns!

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-07-28 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (426 votes). Check out past polls.