Here is a little program I wrote that will download the winning supper lottery numbers and show you which tickets have winning numbers.

I wrote this code to see how the LWP::Simple module works and learn a little bit more about pattern matching. I really suck at pattern matching so I might have not done it the best way, but it works.

Sample Lottery data file: Last number is mega number
4::33::8::7::18::3 5::6::9::14::10::1 9::32::15::3::1::2 6::32::9::15::24::9
zzLOTTOz: check your supper lotto tickets
#!/usr/bin/perl -Tw # zzlottoz # check and see if you win the lottery. use LWP::Simple; my $url = "http://209.210.49.50/winningnumbers.asp"; my $lotto_file = shift || "lotto.txt"; my @numbers = (); my @winners = (); my $mega = ""; my %lotto; open LOTTO, $lotto_file or die "Couldn't open lotto data file: $!\n."; while (<LOTTO>){ my @data = split /::/; push @numbers, [ @data ]; } close LOTTO or warn "Error while closing lotto data file: $!\n."; my $web = get ($url); die "Unable to download lottery numbers.\n" unless (defined($web)); (@winners) = $web =~ /Super Lotto Plus Winning Numbers:\s+(\d{1,2})\s+ +(\d{1,2})\s+(\d{1,2})\s+(\d{1,2})\s+(\d{1,2})\s+Mega\s+(\d{1,2})/s; $mega = pop @winners; die "Error parsing lotto numbers!\n" unless ((@winners) && (defined($m +ega))); foreach my $num (@winners){ $lotto{$num}= 1; } print "\n LOTTO RESULTS: @winners MEGA: $mega\n\n"; print " N U M B E R S MEGA\n"; foreach my $ticket (@numbers){ foreach my $num ( (@$ticket[0..4]) ){ ($lotto{$num}) ? printf(" [%2u] ",$num) : printf (" %2u ",$n +um); } ($$ticket[5] == $mega) ? printf " [%2u] ",$mega : printf " %2u " +,$$ticket[5]; print "\n"; }

Im really starting to like perl! Perl kicks butt!
zzSPECTREz


In reply to California Super Lotto Checker by zzspectrez

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.