Perl Scripts

There are several that are available on my site:

On this page:

Daily Emailer

I find it handy sometimes to be able to confirm that my home computer is connected to the Internet and able to send email. This script when scheduled will send me an email, using an ISP host rather than local MTA and if I need the IP of my home machine, it includes a link to see how to find that as well.

#!/usr/bin/perl
use strict;
use Socket;
use Sys::Hostname;
my $host = hostname();
use Net::SMTP;
my $smtphost="mail.charter.net";
my $smtp=Net::SMTP->new($smtphost);
$smtp->mail("emailusername\@charter.net");
$smtp->to("emailusername\@gmail.com");
$smtp->data;
$smtp->datasend("From: emailusername\@charter.net\n");
$smtp->datasend("To: emailusername\@gmail.com\n");
$smtp->datasend("Subject: Daily Email\n");
$smtp->datasend("\n");
my $body.="This is a daily email sent ".localtime().". This is sent to ensure that I can confirm successful communication.\nTo view headers see gmail at\nhttp://mail.google.com/support/bin/answer.py?answer=22454\n\n<a href=\"http://mail.google.com/support/bin/answer.py?answer=22454\">http://mail.google.com/support/bin/answer.py?answer=22454</a>.\n\nProcess $$\nScript:$0\nHost: $host";
$smtp->datasend($body);
$smtp->dataend;
$smtp->quit;

And I can never remember how to do this:

perl -pi -e 's/string1\.$/string2\./' *.html

see: http://www.debian-administration.org/articles/298