On Wed, Nov 12, 2008 at 15:44, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Tue, Nov 11, 2008 at 17:17, bdy <[EMAIL PROTECTED]> wrote: > snip >> Sorry, I should have mentioned I was an ultra-beginner. Aside from >> using that in a .pl file, how else could I execute that for multiple >> files in a directory? > snip > > #!/usr/bin/perl > > use strict; > use warnings; > > use HTML::TreeBuilder; > > die "usage: $0 FILE(s)\n" unless @ARGV > 0; > > for my $file (@ARGV) { > my $tree = HTML::TreeBuilder->new; > $tree->parse_file($file_name); > print $tree->as_text; > }
Whoops, that would have printed out each file to stdout, this one opens a new file per input file. #!/usr/bin/perl use strict; use warnings; use HTML::TreeBuilder; die "usage: $0 FILE(s)\n" unless @ARGV > 0; for my $file (@ARGV) { my $tree = HTML::TreeBuilder->new; $tree->parse_file($file_name); open my $fh, ">", "$file_name.txt" or die "could not open $file_name.txt: $!"; print $fh $tree->as_text; } -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/