I used to spend a lot of my time reading news sites. Now I spend all of my time doing it. But seriously, I found it was eating into my day, and so I resolved to get most of it over with first thing in the morning by having web pages sent to my inbox from a cron job.

What follows is my script to do this. I've ripped out various installation-specific bits, but it should still work. If I were to rewrite it, I'd probably use File::Temp to handle the temporary files rather than rely on unixisms.

Here's the code. Don't do anything annoying with it; good monks don't do that.

#!/usr/bin/env perl # mailwebpage - send a web page to someone over e-mail # created on 30/8/02001, and badly munged later. # # usage: takes two args; URL, and destination address # example: # mailwebpage # if the URL happens to be a readable file, it does the right thing. use strict; use warnings; use diagnostics; use integer; use MIME::Lite; use LWP::Simple; my $url=shift; # web location if (-r $url) { # if URL is actually a file, $url = 'file:' . $url; # make it so # this'll probably foul up if we get a fs that can resolve urls... } my $recipient=shift; # e-mail recipient my @headarr = head($url); # get the http header if ($#headarr == -1) { die "Can't resolve $url\n"; # if there is nothing there } else { my $tmpfile = "/tmp/foo$$.tmp"; # actual tmp file name on system my $type = $headarr[0]; # Content-Type: getstore($url,$tmpfile); # get page to tmp file my $msg = new MIME::Lite # new mail object To =>$recipient, Subject =>$url, # URL is e-mail subject Type =>$type, Encoding =>'base64', Disposition =>'inline', Path =>$tmpfile; # these fields rooted out from old NS Communicator headers $msg->attr('Content-Base' => $url); $msg->attr('Content-Location' => $url); my $result = $msg->send; unlink $tmpfile; # better tell the good people what went down die "Can't send $url to $recipient\n" unless (defined($result)); } exit;

$,="\n";foreach(split('',"\3\3\3c>\0>c\177cc\0~c~``\0cc\177cc")) {$a++;$_=unpack('B8',$_);tr,01,\40#,;$b[$a%6].=$_};print@b,"\n"