udigthis has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w opendir(DIR,".") || die "couldn't open the directory!"; @files = readdir(DIR); closedir(DIR); print 'There are ',scalar(@files)," files in the directory.\n"; foreach $file (@files) { print "Stored on the server as: $file\n"; print "--------------------------------------------\n"; open (CURRENT, "$file") || die "couldn't open the file!"; while ($fileguts = <CURRENT>) { print " $fileguts"; } print "\n\n\n"; close(CURRENT); }
I'm running this in a directory of text files. As you can see, the result of this is how many files are in the directory and the contents of each file separated with a dashed line printed to screen. What I'd *like* to do is only have files that have filenames ending with *.dat to be involved.
Any input is greatly appreciated.
|
|---|