Hi. Try this with the directory name as the command line argument. Let me know if u have any questions. I really recommend getting one of the O'Reilly books to really get into Perl.
%estparms = map {$_, 1} (18,21..24,28..31,206..208); %popparms = map {$_, 1} (220,223..226,229..233,424..426); $dir = $ARGV[0] or die; @files = glob "$dir/*.txt"; foreach $file (@files) { my $lineno = 0; open FILE, $file; while (my $line = <FILE>) { push @estlines, $line if exists $estparms{$lineno}; push @poplines, $line if exists $popparms{$lineno}; $lineno++; } close FILE; print "FILE\n$file\n"; print "ESTIMATION\n", join "\n", @estlines, ""; print "POPULATION\n", join "\n", @poplines, ""; } At 11:44 AM 3/3/2009 -0600, Bryan Keller wrote: >Hi all, > >The following gets me the lines I need for any single txt file. > >#!usr/bin/perl >use warnings; >use strict; > >my @output = <>; >print "$ARGV"; >print ("\nESTIMATION\n"); >print @output[18,21..24,28..31,206..208]; >print "\nPOPULATION\n"; >print @output[220,223..226,229..233,424..426]; > >These txt files are in groups of 25 (in folders). My goal is to automate this so that after specifying a folder, Perl will pull the specified lines from each of the 25 txt files in that folder and write them to a single output file. > >I would greatly appreciate any help or suggestions! > >Bryan > >------------- >Bryan Keller, Doctoral Student/Project Assistant >Educational Psychology - Quantitative Methods >The University of Wisconsin - Madison >_______________________________________________ >Perl-Win32-Users mailing list >Perl-Win32-Users@listserv.ActiveState.com >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > -- REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=-- "...ne cede malis" 00000100 _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs