G
Geoff Cox
Hello,
I am trying to find <body> in an html file and then add some text to
the line after the <body> tag ... the code below adds the text at the
end of the file. How do I get the text on the next line after
<body>?
Cheers
geoff
use warnings;
use strict;
use File::Find;
my $dir = 'd:/a-winfiles/mfox/html/few';
find sub {
my $name = $_;
if (-d $_) {return;};
if ($name !~ /^print/) {
open (IN, "$name");
my $line;
while (defined ($line = <IN>)) {
if ($line =~ /<body>/i) {
open (OUT,">>$name");
print OUT ("\n freddy");
}
}
}
}, $dir;
I am trying to find <body> in an html file and then add some text to
the line after the <body> tag ... the code below adds the text at the
end of the file. How do I get the text on the next line after
<body>?
Cheers
geoff
use warnings;
use strict;
use File::Find;
my $dir = 'd:/a-winfiles/mfox/html/few';
find sub {
my $name = $_;
if (-d $_) {return;};
if ($name !~ /^print/) {
open (IN, "$name");
my $line;
while (defined ($line = <IN>)) {
if ($line =~ /<body>/i) {
open (OUT,">>$name");
print OUT ("\n freddy");
}
}
}
}, $dir;