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 2014 Edition: Covering 13.10 and 14.04,Ninth 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.