in reply to Simplify code in Perl with "unless" condition

There's a lot of repitition there as you can doubtless see. This suggests a loop. Here's an outline:

#!/usr/bin/env perl use strict; use warnings; my @things = qw/firefox chrome exploder/; while (my $this = shift @things) { for my $that (@things) { print "Now compare $this with $that\n"; } last if $#things < 1; }

You can obviously replace the print statement with whatever block you require for each permutation of entries in @things. HTH.

Replies are listed 'Best First'.
Re^2: Simplify code in Perl with "unless" loop
by Chaoui05 (Scribe) on May 27, 2016 at 15:47 UTC
    Thanks. I will try to find a better solution. And yes , i can doubtless see it..obviously. And what does it mean HTH ?
    Lost in translation

      Hope This Helps


      Give a man a fish:  <%-{-{-{-<

        ^^ Thanks
        Lost in translation