#!/usr/bin/perl use strict; &subdir("."); sub subdir { my $thisdir = shift; unless (opendir(THISDIR, $thisdir)) { warn "Couldn't read dir \"$thisdir\": $!\n"; return; } my $dirfile; my @dirfiles = readdir(THISDIR); closedir(THISDIR); while ($dirfile = shift(@dirfiles)) { next if ($dirfile =~ /^\.\.?$/); my $thisfile = "$thisdir/$dirfile"; my @fstat = lstat $thisfile; # my $usr = getpwuid($fstat[4]); # my $grp = getgrgid($fstat[5]); # -f File is a plain file. # -d File is a directory. # -l File is a symbolic link. # -p File is a named pipe (FIFO), or Filehandle is a pipe. # -S File is a socket. # -b File is a block special file. # -c File is a character special file. # -t Filehandle is opened to a tty. if (-l $thisfile) { print "l"; } elsif (-f $thisfile) { print "f"; } elsif (-p $thisfile) { print "p"; } elsif (-S $thisfile) { print "s"; } elsif (-b $thisfile) { print "b"; } elsif (-c $thisfile) { print "c"; } elsif (-t $thisfile) { print "t"; } elsif (-d $thisfile) { &subdir($thisfile); print "d"; } $thisfile =~ s/^\.\///; print " $fstat[7] $fstat[9] $fstat[4] $fstat[5] $thisfile\n"; } }