#!/usr/bin/perl

# This program uses the opendir()/readdir()/closedir() routines
# to generate a listing of the files in the current directory
# (contrast to "lister" on page 9-6 of the Perl Prog course).

opendir(DIR, ".") || die "Can't open '.'!\n$!";
@files = readdir(DIR);
closedir(DIR);
foreach (@files) {
    next if /^\./;	# Skip if the name starts with a dot
    ($uid, $gid) = (stat($_))[4,5];
#   ($uname) = (getpwuid($uid))[0];
#   ($gname) = (getgrpid($gid))[0];
    print "The file $_ is owned by $uid of the $gid group.\n";
}
exit 0;
