We can check the availability of a folder using Perl as follows :
if(-d "cgi-bin")
{
# directory called cgi-bin exists
}
elsif(-e "cgi-bin")
{
# cgi-bin exists but is not a directory
}
else
{
# nothing called cgi-bin exists
}
As a note, -e
doesn’t distinguish between files and directories. To check if something exists and is a plain file, use -f
.