$classdir = '/mnt/homes/CLASSES/CIS2279/'.$ENV{'LOGNAME'};
$outfile = $classdir.'/lab10.temp';
$directory = '/mnt/homes/CLASSES/CIS2279/LAB10/stuff';
chdir($directory);
opendir(DIR, $directory) || die "cannot open directory: $!";
open(OUT, ">$outfile") || die "Cannot open file: $!";
while($item = readdir(DIR)) {
$fullpath = $directory.'/'.$item;
@info = stat($fullpath);
print "for $item:\n\tsize: $info[7]\n\tmodification time: $info[9]\n".
"\tlast access time: $info[8]\n";
if($info[7] > 10000) {
print "The file, $item, is greater than 10k in size.\n";
print OUT "The file, $item, is greater than 10k in size.\n";
}
if($item =~ /gz$/) {
print "The file, $item, ends in gz\n";
print OUT "The file, $item, ends in gz\n";
}
if($info[4] == 3005) {
print "The file, $item, is owned by uid 3005\n";
print OUT "The file, $item, is owned by uid 3005\n";
}
}
closedir(DIR);
close(OUT);
rename("$outfile", "$classdir/lab10.output");
exit;