Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Alright, Skeeve, that's exactly the way I was headed, but it doesn't take me very long before I'm confounded by it. I find myself always wanting to revert to indices and crush it with brute force exhaustion like a numerical integration in fortran. I rarely find myself disappointed when I trust perl syntax.

Am I correct to think that the keys do not have to be unique? In my mind, the keys would represent the number of times a person has won. Stan won twice and dan won once. How do I marry @frequency to @correct in the script below?

$ perl tim1.pl fan dango 4 4 2 1 $ cat tim1.pl #!/usr/bin/perl -w use strict; use 5.10.0; use Crypt::Random qw( makerandom ); # initialize pseudorandoms my $r = makerandom( Size => 512, Strength => 1 ); # print "$r\n"; srand($r); #populate lists my @winners = qw/stan dan/; my @winner_copy = @winners; my @correct = qw/stan dan fan dango/; my @correct_copy = @correct; #populate hash my %correct; @correct{@correct} = (); delete @correct{@winners}; print join( ' ', keys %correct ), "\n"; my $count = scalar(@correct); print "$count\n"; my @new_list = @correct; $count = scalar(@new_list); print "$count\n"; # if ( scalar(@correct) eq 0 ) my @frequency = (2, 1); # --@frequency; that didn't work print "@frequency", "\n"; # decrement frequency # does anyone with a key value of zero have a correct response yet? # if yes, you have a winner; if not then test whether there was a corr +ect response among those with positive keys. # if no one correct among them, then there was no correct response, be +cause that partitions the sets. $

I tried to map out in pseudoscript what I'm doing here. Obviously, I don't have the parts to make a control that works yet, but the contest just started today, so I don't have to have winner until after the time window closes.

Why does the hash have 4 nodes after 2 have been deleted?

How do I decrement the keys of a hash?


In reply to Re^2: removing a sublist by Datz_cozee75
in thread removing a sublist by Datz_cozee75

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (9)
    As of 2014-10-02 17:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (67 votes), past polls