get_code.pl
Get Perl code from <www.etilem.net>.
Copyright 2000-2007 Etienne LEMEE <coding AT etilem DOT net>
This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
#!/usr/bin/perl -w use strict; use LWP::Simple; use HTML::TokeParser; my $base = "http://etilem.net/code/"; my $p = HTML::TokeParser->new(\get($base)); my @seen; while (my $token = $p->get_tag("a")) { my $url = $token->[1]{href} || "-"; next if $url =~ /(html$|^[\/-]$|^\?)/; $url =~ s/download.php.file=//; unless ($url =~ /p[lm]$/) { push @seen, $url; next; } print "fetching $url : ", status_message(getstore($base . "/" . $url, $url)), "\n"; my $chm = oct 755; $chm = oct 644 if ($url =~ /pm$/); chmod $chm, $url or warn "OOPS, chmod $chm $url failed : $!"; }