Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Lotto checker...

by kcott (Archbishop)
on Apr 15, 2014 at 20:43 UTC ( [id://1082389]=note: print w/replies, xml ) Need Help??


in reply to Lotto checker...

G'day fishy,

Applying this advice from Arunbear and bigj:

my %draw = map { $_ => 1 } qw( ... ); my @bets = ( ... );

You can reduce your original code, which is somewhat difficult to read and maintain, to just this:

print for map { my $hits = grep { $draw{$_} } @$_; "@$_ --> $hits" . ($hits > 2 && ' *') } @bets;

My test code and results are in the spoiler:

-- Ken

Replies are listed 'Best First'.
Re^2: Lotto checker...
by fishy (Friar) on Apr 16, 2014 at 14:22 UTC
    Venerable answers.
    Flexing my mind and stretching my Perl.

    Many Thanks, Monks!

    P.D.
    kcott: just concat "\n" at print argument
      "kcott: just concat "\n" at print argument"

      No. There's no need to do that.

      Look at the full code and output I posted in the spoiler. Note that the output doesn't require additional newlines. Did you run it? Did you get a different result?

      See the first line of that code:

      #!/usr/bin/env perl -l

      Look at "perlrun: Command Switches" to see what the '-l' switch does.

      -- Ken

        Right, Ken.

        I got confused because I ran it with

        /usr/bin/env perl -l

        and got

        /usr/bin/env: perl -l: No such file or directory

        Now, running it with just

        /usr/bin/perl -l

        I get the right result.

        So, no need to append "\n" and another new thing I've learned.


        Thanks a lot!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1082389]
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: (5)
As of 2024-04-23 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found