in reply to Re^2: Permission & size are not visible
in thread Permission & size are not visible

Either prepend the directory name when doing the file tests inside the loop:

my $dir = "/home/gaurav/Documents"; opendir my $dh, $dir or die "Couldn't open $dir: $!"; while (readdir $dh) { next if $_ eq "." or $_ eq ".." ; print $_, " " x (30 - length($_)); my $file = "$dir/$_"; # ...do file tests against $file here }

Or use chdir to change the working directory before entering the loop where you do the file tests:

my $dir = "/home/gaurav/Documents"; opendir my $dh, $dir or die "Couldn't open $dir: $!"; chdir($dir); while (readdir $dh) { next if $_ eq "." or $_ eq ".." ; print $_, " " x (30 - length($_)); # ...do file tests against $_ here }

Replies are listed 'Best First'.
Re^4: Permission & size are not visible
by gaurav (Sexton) on Jun 19, 2013 at 10:09 UTC
    Thanks @smls...Thanks a lote