in reply to Re^2: Simplify code in Perl with "unless" loop
in thread Simplify code in Perl with "unless" condition

When you update your post: use strike tags and then put in correction. If you change the question mid-stream, posts to the original question are confusing. Make this update explicit.

And yes "unless" is just the "NOT of if". These are all the "same".

#!/usr/bin/perl use strict; use warnings; my $x = 5; print "x not 3\n" unless $x==3; print "x not 3\n" if $x!=3; print "x not 3\n" if !($x==3);
Usually the "if version" is more clear. However in the above, since $x is seldom exactly 3, "unless" focuses on the usual action with Perl's ability to put the "action" first and the conditional last. For longer blocks, most often use some form of "if".

Replies are listed 'Best First'.
Re^4: Simplify code in Perl with "unless" loop
by Chaoui05 (Scribe) on May 27, 2016 at 16:28 UTC
    I will Marshall . Thanks for reply
    Lost in translation