Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Frontpage staleness detector

by diotalevi (Canon)
on Mar 17, 2004 at 16:50 UTC ( #337404=sourcecode: print w/replies, xml ) Need Help??
Category: PerlMonks Related Scripts
Author/Contact Info

This fetches the front page, does a quick guess at which nodes are questions and produces a histogram of the dates and how many nodes there are from each. I use it to check when the page is getting old and people aren't front-paging enough.

It'd be nicer if someone else were to package this into a CGI (remember to use a cache) and give us all a link. Or better yet... have to auto /msg people or tell the CB or something.

use strict;
use warnings;
use LWP::Simple 'get';
use vars qw( $URL );

$URL = '';

exit main( @ARGV );

sub main
    my $continue = 1;
    my $prev     = ~0;
    my %days;

        grep {
            $continue && $_ <= $prev
                ? do {
                    $prev = $_;
                    $continue }
                : do { $continue = 0 } }
        get( $URL ) =~
              (?s:.+?) on \s+
              [ADFJMNOS]\S+ \s+
              at \s+[\d:]+)xigs;

    print "Dates of nodes on the Monastery Gates\n"
        . join '',
          map sprintf( "% 02d: %s\n",
                        '*' x $days{$_} ),
          sort { $b <=> $a }
          keys %days;

Replies are listed 'Best First'.
Re: Frontpage staleness detector
by allolex (Curate) on Mar 17, 2004 at 17:00 UTC

    I'm curious about this structure:

    exit main( @ARGV ); ... sub main{}

    Why are you using it? (style, efficiency?)


      It makes clear that there isn't some other code at file scope-level that isn't going to run later and less visibly. I just do this for scripts.
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://337404]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2018-02-23 15:00 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.