Govind
It was very kind of you to take the trouble to write that script and,
although my Perl is not especially good, I should be able to make a few
modifications so that it will go through all files in a specified
directory.
So, yes, it does help. Thank you very much.
--
Barry Samuels
http://www.beenthere-donethat.org.uk
The Unofficial Guide to Great Britain
On 02/11/10 19:00:27, Govind Chandra wrote:
> Hi Barry,
>
> I think the perl script below (or some modification thereof) will do
> what you want.
>
> =====================================================
>
> #! /usr/bin/perl
> use strict;
>
> open(INFILE, "<$ARGV[0]");
>
> my $social_flag = 0;
>
> while(<INFILE>) {
> my $line=$_;
> chomp($line);
>
>
> if($line=~m/<table class="socialheader"/) {
> $social_flag = 1;
> print("$line\n");
> next;
> }
>
> if($line=~m/align="left"/
> and $line=~m/width="85%"/
> and $line=~m/nowrap/
> ) {
> if($social_flag) {
> print("$line\n");
> print("One new line here\n");
> print("Another new line here\n");
> $social_flag = 0;
> }
> else {
> print("$line\n");
> }
> }
> else {
> print("$line\n");
> }
>
> }
>
> close(INFILE);
>
> ==============================================================
>
> Hope this helps.
>
> Govind
>
> > Subject: [ALUG] Search and replace(insert) - can anyone help?
> > To: Alug
main@lists.alug.org.uk
> > Message-ID:
1288625418.1815.0@dataman1
> > Content-Type: text/plain; charset=us-ascii
> >
> > <table class="socialheader" width="100%" border="0">
> >
> > <tr>
> > <td width="85%" align="left" nowrap>The Three Sisters, Glen Coe</td>
> > </tr>
> >
> > </table>
> >
> > I have over 2500 pages with the above HTML in ( the "Three Sisters,
> Glen
> > Coe" bit is different in every file) and I want to add two lines so:
> >
> > <table class="socialheader" width="100%" border="0">
> >
> > <tr>
> > <td width="85%" align="left" nowrap>The Three Sisters, Glen Coe</td>
> > <One new line here>
> > <Another new line here>
> > </tr>
> >
> > </table>
> >
> > The pair of lines to be inserted is identical in each case but the
> only
>
> > unique identifier is the "class=socialheader".
> >
> > Is there any way I can do it with a script?
> >
> > --
> > Barry Samuels
> >
http://www.beenthere-donethat.org.uk
> > The Unofficial Guide to Great Britain
>
> _______________________________________________
> main@lists.alug.org.uk
>
http://www.alug.org.uk/
>
http://lists.alug.org.uk/mailman/listinfo/main
> Unsubscribe? See message headers or the web site above!
>