Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Simplify code in Perl with "unless" loop

by Chaoui05 (Scribe)
on May 27, 2016 at 15:42 UTC ( [id://1164325]=note: print w/replies, xml ) Need Help??


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

Oh yes ! I did a big mistake. INdeed, it's a conditionnal and not a loop..end of week Thanks , i changed it in my post edit
Lost in translation

Replies are listed 'Best First'.
Re^3: Simplify code in Perl with "unless" loop
by Marshall (Canon) on May 27, 2016 at 15:59 UTC
    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".
      I will Marshall . Thanks for reply
      Lost in translation

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1164325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found