On Thu, May 06, 2004 at 03:28:51PM -0700, Lino Iozzo wrote:
> Here is an example:
>  
> I have a file and save it to a directory whether it is one file or multiple files 
> then i go to my perl script and type retrievelist.pl this should look into the 
> specified directory in the code and display everything in this directory.
>  
> Then retrieve list should prompt the user to select one of the files it returned and 
> then this would invoke another perl command called parselist.pl.
>  
> this should all take place in the retrieve list for now until i build a menu 
> system...and i don't know when this will happen.
>  

Well without still more info such as what you want to do with the list this script 
will read the current directory and store all the file names into an array. You could 
use a hash or even process each file one at a time. Code is untested. 

HTH,
Paul Kraus


Code
-=-=-=

use strict;
use warnings;

my @files;
while ( <*> ) {
        next if ( /\.|\../ ); # skip the '.' and '..' directory
        my $filename = $_;
        push ( @files, $filename );
        #### or you could process each file as it is found ...
        open ( IN, "<$filename" ) or die (" could not open file $!\n" );
        while ( <IN> ){
                ###Parse file here
        }
}
        


foreach my $ file ( @files ) {
        open ( IN, "<$file" ) or die (" could not open file $!\n" );
        while ( <IN> ){
                ###Parse file here
        }
}


-- 
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