!#/usr/bin/perl use strict; use CommonOutput; use TestParsers; ( @ARGV == 1 and -d $ARGV[0] ) or die "Usage: $0 pathname\n pathname : directory containing files to process\n"; chdir $ARGV[0] or die "chdir $ARGV[0] failed: $!\n"; # let's suppose that TestParsers can tell which parsing # function is needed based on the path (because the path # identifies both the source and the type of content): my $parser = TestParsers->new( $ARGV[0] ); my $emitter = CommonOutput->new(); for my $infile ( <*.txt> ) { # or whatever works for your files if ( open( IN, "<", $infile )) { local $/ = undef; $_ = ; close IN; emitter->print( $parser->( $_ )); } else { warn "unable to open $infile: $!\n"; } }