Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have to edit an html file. The problem is I have to delete a whole paragraph depending on certain pattern recognition and then add another para with some other text at some other location in the file. How do I delete a whole para and then add another one at some other location? Thanks!!

Replies are listed 'Best First'.
Re: Editing file
by jeroenes (Priest) on Oct 01, 2001 at 21:43 UTC
    With such a description we can give only general advice (also smells a bit like homework), see perlrun, for, split and perlop:
    /usr/bin/perl -i.bak @pars= split /\n\n/, join '', <>; for( @pars ){ next if /pattern1/; print $newpara if /pattern2/; print; print "\n\n"; }
    Jeroen