[perl]代码库
#-----------------------------
# download the following standalone program
#!/usr/bin/perl -w
# surl - sort URLs by their last modification date
use LWP::UserAgent;
use HTTP::Request;
use URI::URL qw ( url );
my ( $url, %Date );
my $ua = LWP::UserAgent->new();
while ( $url = url ( scalar <> ) )
{
my ( $req, $ans );
next unless $url->scheme =~ /^ ( file|https? ) $/;
$ans = $ua->request ( HTTP::Request->new ( "HEAD", $url ) );
if ( $ans->is_success )
{
$Date {$url} = $ans->last_modified || 0;
# unknown
}
else
{
print STDERR "$url: Error [", $ans->code, "] ", $ans->message, "!\n";
}
}
foreach $url ( sort { $Date{$b} <=> $Date{$a} } keys %Date )
{
printf "%-25s %s\n", $Date {$url} ? ( scalar localtime $Date {$url} )
: "<NONE SPECIFIED>", $url;
}
#-----------------------------
#% xurl http://www.perl.com/ | surl | head
#Mon Apr 20 06:16:02 1998 http://electriclichen.com/linux/srom.html
#
#Fri Apr 17 13:38:51 1998 http://www.oreilly.com/
#
#Fri Mar 13 12:16:47 1998 http://www2.binevolve.com/
#
#Sun Mar 8 21:01:27 1998 http://www.perl.org/
#
#Tue Nov 18 13:41:32 1997 http://www.perl.com/universal/header.map
#
#Wed Oct 1 12:55:13 1997 http://www.songline.com/
#
#Sun Aug 17 21:43:51 1997 http://www.perl.com/graphics/perlhome_header.jpg
#
#Sun Aug 17 21:43:47 1997 http://www.perl.com/graphics/perl_id_313c.gif
#
#Sun Aug 17 21:43:46 1997 http://www.perl.com/graphics/ora_logo.gif
#
#Sun Aug 17 21:43:44 1997 http://www.perl.com/graphics/header-nav.gif
#-----------------------------
by: 发表于:2017-09-18 17:48:35 顶(0) | 踩(0) 回复
??
回复评论