Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Search and replace in portion of xml file

by Jenda (Abbot)
on Jun 01, 2009 at 22:22 UTC ( #767397=note: print w/replies, xml ) Need Help??


in reply to Search and replace in portion of xml file

use XML::Rules; my $parser = XML::Rules->new( style => 'filter', rules => { article => sub { my ($tag,$attr) = @_; $attr->{_content} =~ s/EM/E/g; return $tag => $attr; } } ); $parser->filterfile( 'a.xml', 'b.xml');

Jenda
Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^2: Search and replace in portion of xml file
by sandy1028 (Sexton) on Jun 02, 2009 at 09:27 UTC
    Thanks for all the replies. I am trying to replace the text ctrl+O which is ^O in the file.
    open FH,'a.txt'; @data=<FH>; foreach $dat (@data){ $dat =~ s/\^O/ /g; }
    I am trying to replace the control characters with a space but no luck. Please can you suggest me how to proceed

      Perl doesn't understand what do you mean by that \^O. Try \x0F instead.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-12-08 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (36 votes). Check out past polls.

    Notices?