#!/usr/bin/perl -w use strict; my $dir = "."; # relative path within chroot opendir(DIR, $dir) or die "can't open $dir for read: $!\n"; my @file = readdir DIR; closedir(DIR) or die "error closing $dir: $!\n"; foreach my $file (@file) { my $fsize = (-s $file); # get the file size my $isdir = (-d $file); # get the file size if ($fsize > 1 || $isdir =~ 1) { print ":$file:$fsize:$isdir:\n"; ...do more junk.... } else { print ":$file:$fsize:$isdir:\n"; ...do more junk.... } }