What does the exclamation point mean in the this example? The one right before 'open'? The book can't answer my question..
if ( ! open PASSWD, "/etc/passwd") {
die "How did you get logged in? ($!)";
}
while (<PASSWD>) {
chomp;
...
}
!
is the boolean negation operator.
open(...)
returns false on error and true on success.
Therefore, !open(...)
returns true on error and false on success.
The if
's block is executed if the expression (!open(...)
) is true.
Therefore, the if
's block is executed if open
returned an error.
Perl's symbolic operators are documented in perlop.