Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Just Another Lotto Script

by scain (Curate)
on Mar 06, 2002 at 16:10 UTC ( [id://149722]=note: print w/replies, xml ) Need Help??


in reply to Just Another Lotto Script

Could you be a little more specific than "I don't think I'm going about some things in the right way"?

Does it not compile? Do you not get the results you exect? How are they different from what you expect? Why do you expect us to believe you don't play the lottery?

Scott

Replies are listed 'Best First'.
Re: Re: Just Another Lotto Script
by draper7 (Scribe) on Mar 06, 2002 at 16:34 UTC
      Scott, everything works like I want it to I'm just curious about a couple of parts ->
    ## 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);
       --JD
      Sorry, I missed your comments in the code.

      Well, of course the two short answers are "if it works..." and "TMTOWTDI". I guess neither of those are what you're looking for.

      In general, there is nothing wrong with what you did. One style point though: when you open a file, always check that it completed successfully:

      open HTML, ">html.txt" or die "couldn't open html.txt: $!\n";
      Writing it to a file is a good idea, at least in development stages, that way you know what you've got. Would you rather not write the html file? You could "stringify" @html, if no other way than with a foreach loop:
      foreach my $line (@html) { $html .= $line; }
      Seem reasonable?

      Scott

        If you want to concatenate all elements of a list, use the function that was made to do exactly so: join.

        my $html = join '', @html;

        ++ vs lbh qrpbqrq guvf hfvat n ge va Crey :)
        Nabgure bar vs lbh qvq fb jvgubhg ernqvat n znahny svefg.
        -- vs lbh hfrq OFQ pnrfne ;)
            - Whreq
        

          Yeah, thats what I was looking for.
        ## i shouldn't do this, should i? # #open(HTML,">html.txt"); #print HTML @html; #close(HTML); my $html; foreach my $line (@html) { $html .= $line; } ## 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"); ## changed $lotto to $html $extract->parse($html); foreach $ts ($extract->table_states) { foreach $row ($ts->rows) { print NUMBERS join(":", @$row), "\n"; } } close(HTML); close(NUMBERS);
           --JD

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://149722]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-23 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found