unless

unless works just like if, only backward. unless performs a statement or block if a condition is false:

unless ($name eq "Rich")        {  print "Go away, you're not allowed in here!\n";}

Note

You can restate the preceding example in more natural language, like this:

print "Go away!\n" unless $name eq "Rich";

Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.