Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!c:\\perl\\bin\\perl.exe # Slashdot Headline Grabber for Win32 # by Joe Stewart use Win32::GUI; use Win32::Shell; use Socket; my $count; my %stories; my @keys; my $maxsize = ([400,42]); my $minsize = ([200,42]); my $main = Win32::GUI::Window->new(-name => 'Main', -text => 'Slashdot Headlines', -width => 275, -height => 42, -maxsize => $maxsize, -minsize => $minsize); my $label = new Win32::GUI::Label($main, -text => "Downloading Headlines...", -name => "Url", -width => 350, -height => 42, -left => 40, -notify => 1); my $button_back = new Win32::GUI::Button($main, -text => "<", -name => "Back", -width => 15, -left => 0, -height => 15); my $button_fwd = new Win32::GUI::Button($main, -text => ">", -name => "Fwd", -width => 15, -left => 15, -height => 15); $main->AddButton($button_back); $main->AddButton($button_fwd); $main->AddLabel($label); my $Cycle = $main->AddTimer("Cycle", 10000); my $Reload = $main->AddTimer("Reload", 1800000); $main->Show(); GUI::Update($main); my $inet = inet_aton('www.slashdot.org'); my $proto=getprotobyname('tcp'); &fetch_headlines; $main->Url->Text($stories{$keys[0]}); $Cycle->Interval(10000); Win32::GUI::Dialog(); sub Main_Terminate { -1; } sub Fwd_Click { $count++; $count = 0 if $count == scalar(@keys); $main->Url->Text($stories{$keys[$count]}); $Cycle->Interval(10000); } sub Back_Click { $count--; $count = scalar(@keys) - 1 if $count == -1; $main->Url->Text($stories{$keys[$count]}); $Cycle->Interval(10000); } sub Url_DblClick { my $url = $keys[$count]; Win32::Shell::Execute("open", $url, undef, undef, "SW_SHOWNORMAL"); return 1; } sub fetch_headlines { my @D; socket(S,PF_INET,SOCK_STREAM,$proto) || return 0; if(connect(S,pack "SnA4x8",2,80,$inet)) { select(S); $|=1; print "GET /slashdot.xml HTTP/1.0\n\n"; @D=<S>; select(STDOUT); close(S); } else { return 0 } my ($title, $url); for (@D) { $title = $1 if /\<title\>(.*)\<\/title\>/; $url = $1 if /\<url\>(.*)\<\/url\>/; if (/<\/story>/) { $stories{$url} = $title; push(@keys, $url); $title = ""; $url = ""; } } return 1; } sub Cycle_Timer { &Fwd_Click; return 1; } sub Reload_Timer { &fetch_headlines; $Reload->Interval(1800000); return 1; }

In reply to Slashdot Headline Grabber for Win32 by httptech

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (6)
    As of 2014-04-19 02:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (475 votes), past polls