A L wrote: > > Let's say there is a directory called Top. Within the Top > directory, there are 26 subdirectories named A-Z. Within each > of those A-Z subdirectories contain one or more filess that > ends in .txt extension. Now, to print out the content within > all those .txt files, what can you do to not type in each > separate directory handle and file handle? I've written the > following: > #!/usr/bin/perl -w > use CGI ':standard'; > opendir (TOP, '/home/Top/*/'); > while (<TOP>){#a loop to go through all the subdirectories > print $_; #prints a list of subdirectories names A-Z > if (open (FILEH, "*.txt")){#opens a subdirectory A then finds .txt file > while (<FILEH>){#prints contes of all the files that ends in .txt > print $_; > } > } > } > closedir(TOP); > > In the command line when I type perl file name, I want a list of > directories, then, all the contents of .txt files while going to > through each subdirectories.
This should work: { local @ARGV = glob '/home/Top/*/*.txt'; print while <>; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]