in reply to Customised error messages

use strict; use warnings; my @dirs = qw ( /root /home /sbin /tmp /lost+found /not-a-dir /etc/pas +swd ); for (@dirs) { if (! -e ) { print "$_ => does not exist"; next; } if (! -d ) { print "$_ => not a directory"; next; } (opendir(my $FH, $_)) ? print "$_ => ok" : print "$_ => denied"; } __END__ $ perl -l 621211.pl /root => denied /home => ok /sbin => ok /tmp => ok /lost+found => denied /not-a-dir => does not exist /etc/passwd => not a directory
Update: Added tests on existence and type.

Replies are listed 'Best First'.
Re^2: Customised error messages
by denzil_cactus (Sexton) on Jun 15, 2007 at 06:12 UTC
    well its not working because as soon as it checks for the files which are not accessible gives the output "the directory does not exist" which is actually because of permission problem... And my concern is regarding inside any home directory like /home/denzil/temp or /home/jessica/tmp... Please tell me how to suppress the default error I mean to catch the default error and put the condition for that