Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Simplify code in Perl with "unless" conditionnal

by choroba (Cardinal)
on May 30, 2016 at 12:49 UTC ( [id://1164498]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Simplify code in Perl with "unless" conditionnal
in thread Simplify code in Perl with "unless" condition

If you want to replace @browsers with @random_array, you need to do it everywhere. You only used the random array to get the indices, which are in fact the same as in the original. Replace all mentions of @browsers by @random_array (except the one where you shuffle it, of course).

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^6: Simplify code in Perl with "unless" conditionnal
by Chaoui05 (Scribe) on May 30, 2016 at 13:22 UTC
    I did it but nothing changes. Have i to do it with "shuffle" or there is another way ?
    Lost in translation
      What do you mean by "nothing changes"? I'm getting different output on each run:
      #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use List::Util qw{ shuffle }; my @browsers = ('firefox', 'chrome', 'internet explorer'); my %screen = map { $_ => "$_\'s screen" } @browsers; my @random_array = shuffle(@browsers); for my $b1_idx (0 .. $#random_array - 1) { my $b1 = $screen{ $random_array[$b1_idx] }; for my $b2_idx ($b1_idx + 1 .. $#random_array) { my $b2 = $screen{ $random_array[$b2_idx] }; say "About to compare $b1 with $b2"; } }
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        I wanted to say i have the same output. But it's ok indeed! It's just because sometimes, i have different sizes between browser screenshots. Compare & difference methods work with exact same size screenshots in Selenium::Screenshot package. Thanks for reply choroba !
        Lost in translation
        I have got one question . Why did you add 1 in line below:
        for my $b2_idx ($b1_idx + 1 .. $#random_array) {

        +1

        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://1164498]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-19 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found