In-Class Assignment #8
This assignment will introduce you to using some of the standard and CPAN modules available for Perl.
Write a program to search a directory structure and display all files found within. For each file found, display the full path to the file as well as the date/time the file was last modified.
Use Getopt::Long to allow the user to provide
the following arguments on the command line:
--dir- the name of the directory to begin recurseively searching.--size- a number of bytes. Your program should skip over any files that are smaller than this size.--addr- an email address
For each file found, print out that file, as well as it's Last
Modified date. This information can be found via:
my $last_mod = (stat($file))[9];
That will return to you a time stamp (ie, number of seconds since
the epoch). Convert this time stamp to a human readable format,
using POSIX's strftime function. For example
if a file was modified at 1:15pm today, your program should print out
Thursday, April 1, 2010 1:15PM
For a bonus half-point, if the user supplied the --addr option,
then use the Mail::Send module to email the file listing
to the address specified (in addition to printing it to the screen).
Make the subject of the email be "<RCSId>: ICA 8 results". Make sure
to substitute your own RCS Id for <RCSId>
Sample Output
If you run your program with arguments
--dir /cs/lallip/public --size 20,
you should receive the following output:
/cs/lallip/public/submit.pl => Thursday, February 18, 2010 08:18AM /cs/lallip/public/ica2.pl => Thursday, February 11, 2010 09:54AM /cs/lallip/public/BankAccount.pm => Thursday, March 25, 2010 09:26AM /cs/lallip/public/ica2/three.txt => Thursday, February 11, 2010 09:22AM /cs/lallip/public/ica1/a/beta.txt => Wednesday, January 28, 2009 12:08PM /cs/lallip/public/ica1/a/alpha.txt => Wednesday, January 28, 2009 12:06PM /cs/lallip/public/ica1/b/one.txt => Wednesday, January 28, 2009 12:09PM /cs/lallip/public/ica1/b/two.txt => Thursday, February 4, 2010 08:32AM /cs/lallip/public/ica1/b/three.txt => Thursday, February 4, 2010 08:33AM /cs/lallip/public/ica1/c/only.txt => Thursday, February 4, 2010 08:36AM /cs/lallip/public/hw1b/toys.txt => Sunday, February 8, 2009 06:47AM /cs/lallip/public/hw1b/gargoyles => Sunday, February 8, 2009 06:52AM /cs/lallip/public/hw1b/trek.opn => Sunday, February 8, 2009 06:55AM
Submission Instructions
To submit, log on to solaris.remote.cs.rpi.edu and run the program
~lallip/public/submit.pl. You may submit infinite times, only the last
submission will be graded. Your final submission is due at 4pm today,
Thursday, April 1, 2010
