AstroDrabb wrote:
Does anyone know if there are any Perl scripts out there that will do
the following:

I want a script that gets pointed to a directory and searches that
directory and all
sub-directories for *.html (or I can just pass all the files to it
with a simple find
command) .  When it finds an *.html file it reads it in and searches
for a simple
start tag like <!-- Begin scan --> and grabs all the HTML after the
tag until it finds
an end tag like <!-- End scan --> and just concats that to one big HTML file.

#!/usr/bin/perl use warnings; use strict; use File::Find;

# get dir names from command line or use default of current dir
my @dirs = @ARGV ? @ARGV : '.';

my $big_html_file = '/home/astro/big_file.html';

open OUT, '>', $big_html_file or die "Cannot open $big_html_file: $!";

find( sub {
    return unless /\.html$/;
    open HTML, '<', $_ or die "Cannot open $File::Find::name: $!";
    local $/;
    print OUT <HTML> =~ /<!-- Begin scan -->(.*)<!-- End scan -->/s;
    }, @dirs );

__END__



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to