Hey everyone. This is just another Lotto script written out of boredom. I really need some advise as to what I'm doing wrong in my code. The script works but I need some expert tips because I don't think I'm going about some things in the right way. By the way, I don't play the lottery I just find randomness very interesting.
#!/usr/bin/perl -w ## georgia cash 4, drawings every day. ## pretty good odds, not that i ever play. # use strict; use LWP::Simple; use HTML::TableExtract; use Date::Calc qw(Today Day_of_Week Add_Delta_Days Day_of_Week_to_Text Date_to_Text Date_to_Days Decode_Date_US); my @today = Today(); my $current_dow = Day_of_Week(@today); my @lotto_dates;
my $end_date; ## calculate what days there were lotto # my @prev_day = Add_Delta_Days(@today,0); ## # they started midday drawnings... $end_date = "2/5/2001\n"; for (;;) { @prev_day = Add_Delta_Days(@prev_day,-1); my ($sat_year,$sat_month,$sat_day) = Add_Delta_Days(@prev_day,0); my $sat_date = "$sat_month\/$sat_day\/$sat_year\n"; if ($sat_date eq $end_date) { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:M\n"); push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); last; } else { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:M\n"); push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); } } ## # theres no midday drawnings past this day... $end_date = "4/6/1997\n"; for (;;) { @prev_day = Add_Delta_Days(@prev_day,-1); my ($sat_year,$sat_month,$sat_day) = Add_Delta_Days(@prev_day,0); my $sat_date = "$sat_month\/$sat_day\/$sat_year\n"; if ($sat_date eq $end_date) { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); last; } else { push(@lotto_dates,"$sat_month\/$sat_day\/$sat_year\:E\n"); } } ## # there are 131 dates on one page my @html; my $count = 131; foreach my $line (@lotto_dates) { if ($count == 131) { my $url = "http://www.georgialottery.com/lottery/win.cgi?game= +7&ten=yes&enddate=$line"; my $url_data = get $url; push(@html,$url_data); $count = 0; } $count++; } ## i shouldn't do this, should i? # open(HTML,">html.txt"); print HTML @html; close(HTML); ## extract table info from array # my $extract = new HTML::TableExtract( headers => ['Date','Numbers'] ); my $ts; my $row; undef $/; ## help? # open(HTML, "html.txt"); my $lotto = <HTML>; close(HTML); open(NUMBERS, ">c4_numbers.txt"); $extract->parse($lotto); foreach $ts ($extract->table_states) { foreach $row ($ts->rows) { print NUMBERS join(":", @$row), "\n"; } } close(HTML); close(NUMBERS);

--JD

In reply to Just Another Lotto Script by draper7

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.