My only suggestion, since I knew I wouldn't be able to handle reading through this, is to clean up your code. Make it look nice. That may sound very picky and worthless, but really it is very helpful for anyone trying to understand your code.

This may seem kinda stupid, and I can't really explain why I have this preference - maybe it's for general aesthetic appeal, which frankly is important to my stress levels when maintaining code - but drop the long lines of pound signs/comment signifiers/whatever you want to call em.

# USER VARIABLES # define number of people, number of prizes, number of draws (> 5) my $people = 10; my $prizes = 8; my $draws = 22*2; # define total set of BINGO numbers # range of numbers my $range = 75; # INTERNAL/DEVELOPMENT VARIABLES my $bin = int $range/5; my @bins = ($bin, 2*$bin, 3*$bin, 4*$bin); #my @seq = @fudgedDrawSeq; my (@callseq, @noncallseq); #auxillary lists to build my @winstring; # MAIN EXECUTION 1 # * this part used to define metadata; cards outputed from metadata # * this metadata needed so Matt can have the draw sequence now. # my %ball; #hash containing $range BINGO balls THIS SHOULDN'T BE HERE # my @drawSeq; #for &defDrawSeq, draw sequence ... # for ($draws..($range-1)){push( @noncallseq, $seq[$_] ); print "$seq[ +$_], ";} # &mkWinstring; # unless (&chkWinstring){die "\nplease rerun, internal randomization e +r +ror"} # &mkCards; # FUNCTIONS 1 sub ...

Try to put one comment at the beginning of a 'block' of code, and seperate these blocks with an empty line. And if you consistently put all of your subs at the end of your files (like it looks like you do), then people will see your first sub declaration and assume that the rest of the file is subs. So you probably don't even need to denote that with a # FUNCTIONS 1 comment.

And then in your second piece of code, try this. I didn't change any of your code, I just added indents, and put newlines in places. It immediately made the code a lot more understandable. For one, I didn't even realize there was a while block on the first glance, but after showing the blocks better, it's more obvious that these are looping until they return. Also, after indenting and putting things on seperate lines, I realized that you try to print after you return from the sub.

sub getRand { my $temp; while (1) { $temp = int(1111*rand()/11); unless ($temp == 0) { return $temp } } }; sub getDrawBall { my $type = shift; while (1) { my $temp = pop @callseq; unshift( @callseq, $temp ); if ($temp =~ /$type/) { return $temp; print "DEBUG getDrawBall: $temp\n"; } } } sub getNonDrawBall { my $type = shift; while (1){ my $temp = pop @noncallseq; unshift( @noncallseq, $temp ); #print "sNDB\:\: TEMP $temp TYP +E $type\n"; if ($temp =~ /$type/) { return $temp; print "DEBUG getnonDrawBall: $temp\n"; } } }

I guess the point I'm trying to make is try to keep your code clean and looking nice. You'll find it does wonders.

    -Bryan


In reply to Re: "Biochem BINGO" or "Noob Seeks Zen Thrashing" by mrborisguy
in thread "Biochem BINGO" or "Noob Seeks Zen Thrashing" by NamfFohyr

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.