http://qs321.pair.com?node_id=107385

   1: #!/usr/bin/perl -w
   2: use strict;
   3: 
   4: # Lately everyone's been caught up in Powerball fever
   5: # (the jackpot is ~$280 million at time of writing),
   6: # so people around my office were starting to play, and
   7: # I wrote this to analyze the winning numbers history
   8: # text file that powerball.com offers.
   9: 
  10: # (I promise that if I win, I'll donate heavily! :)
  11: 
  12: my ( %numbers, %powerballs, %powerplays );
  13: 
  14: while ( <> ) {
  15:     next if /^!.*$/;
  16:     next if /^\s+$/;
  17:     chomp( my @data = split / / );
  18:     my $date = shift @data;
  19:     $powerplays{pop @data}++ if ( $#data == 6 );
  20:     $powerballs{pop @data}++;
  21:     $numbers{$_}++ foreach @data;
  22: }
  23: 
  24: open OUT, ">powerball.txt" or die "Can't open output file: $!";
  25: 
  26: print OUT <<REGULAR;
  27: Regular Numbers:
  28: Num\tCount
  29: ---\t-----
  30: REGULAR
  31: 
  32: foreach ( sort { $numbers{$b} <=> $numbers{$a} } keys %numbers ) {
  33:     print OUT $_, "\t", $numbers{$_}, "\n";
  34: }
  35: 
  36: for ( 1..49 ) {
  37:     print unless ( $numbers{ sprintf( "%02u", $_ ) } );
  38: }
  39: 
  40: print OUT <<POWERBALL;
  41: 
  42: Powerball Numbers:
  43: Num\tCount
  44: ---\t-----
  45: POWERBALL
  46: 
  47: foreach ( sort { $powerballs{$b} <=> $powerballs{$a} } keys %powerballs ) {
  48:     print OUT $_, "\t", $powerballs{$_}, "\n";
  49: }
  50: 
  51: for ( 1..42 ) {
  52:     print unless ( $powerballs{ sprintf( "%02u", $_ ) } );
  53: }
  54: 
  55: print OUT <<POWERPLAY;
  56: 
  57: Powerplay Numbers:
  58: Num\tCount
  59: ---\t-----
  60: POWERPLAY
  61: 
  62: foreach ( sort { $powerplays{$b} <=> $powerplays{$a} } keys %powerplays ) {
  63:     print OUT $_, "\t", $powerplays{$_}, "\n";
  64: }
  65: 
  66: close OUT;