Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does '! -e "/etc/httpd"' in Perl in 'if' Condition

Tags:

linux

perl

Please explain what following code snippet could do in Perl script,

if (! -e '/etc/httpd') {
   print "Something";
}

I can't find exact scenario or condition that makes this condition 'true'. This question also not explain much regarding this.

Exactly, what -e switch does in this condition?

like image 620
Sachith Dickwella Avatar asked Aug 10 '18 05:08

Sachith Dickwella


1 Answers

The -e filename is one of filetests ("-X"), which checks for existence of a "file" (an entry, not only a plain file).

So the condition tests whether /etc/httpd does not exist, since the unary operator ! does logical negation of what is on its right-hand side using Perl's rules for truth and falsehood.

like image 114
zdim Avatar answered Oct 22 '22 07:10

zdim