Chris Federico wrote: > > Hi List , Hello,
> I have a directory that I want to read . Lets say the name of the directory > is my scripts (Windows platform ) . In this directory is text files . What I > want to do is read the directory and extract 2 lines out of each text file . > So far I'm able to create an Array but I'm not sure how to now read the text > files and extract 2 lines (they are dynamic as far as info but always the > same line numbers) . Here is what I have so far : > > #!/usr/bin/perl -w > > use strict; > opendir(MYSCRIPTS, 'c:\support\my scripts') || die "cannot open my scripts: > $!"; > @FILES=readdir MYSCRIPTS; > # reads the contents of the directory This is reading all files (subdirectories, etc.) from 'c:\support\my scripts' and storing the list in the array @FILES. > closedir(MySCRIPTS); > > @FILES=<*.txt>; > #Glob only the text files This is reading all files (subdirectories, etc.) that have '.txt' at the end of their names from the current directory and storing the list in the array @FILES. > Thats what I got so for . I would like to know if I'm going about it the > right way or is there a better way to go . Please keep in mind that I'm a > beginner . :) It looks like you want to filter the output of readdir() so that only files that end with '.txt' are stored in @FILES. my @FILES = grep /\.txt$/i, readdir MYSCRIPTS; OR include the complete path in the file glob my @FILES = <c:/support/my scripts/*.txt>; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]