#!/usr/bin/perl #InventoryReport.pl use warnings; use strict; use File::Find; open (OUT, ">InventoryFile.txt") or die "Couldn't open output file\n"; my $directory = '//InstallBox/C'; find (\&wanted, $directory); sub wanted { print OUT "$File::Find::name"; } # # Lines 4 and 5 are good Perl practice. "strict" and "warnings" are pragmas # that help prevent Perl programmers from doing silly things in their programs. # # Line 6 is Perl's way of invoking a "module". Modules are sophisticated chunks # of code with simple interfaces for use by Perl programmers. I don't have to # write my own recursive filesystem prober, I can just use File::Find and let # it do the work for me. # # Line 8 "open" statement with the ">" purges any contents if the file exists. # If there's a problem, the program will "die" with an error msg. # # Edit line 11 so that "my $directory" points to your own top-level directory. # I've used Windows syntax here, but the script works just fine on other OSs. # # Lines 13-16 are the basic implementation of File::Find. # Do "perldoc File::Find" for details. # ######################################################