unless statement in perl behaves just opposite to the if statement in perl. It executes the set of statements inside its body when the given condition is false.
unless(condition) { statement(s); }
The statements inside unless body would execute when the condition is false.
Example
#!/usr/local/bin/perl printf "Enter any number:"; $num = <STDIN>; unless($num>=100) { printf "num is less than 100\n"; }
Output:
Enter any number:99 num is less than 100
Leave a Reply