View Category

Check your language appears on the langref.org site

Your language name should appear within the HTML found at the http://langreg.org main page.
perl
# requires libwww-perl
use LWP::Simple;

if (grep /perl/, get('http://langref.org/')) {
print 'perl appears on langref.org';
} else {
print 'perl does not appear on langref.org';
}

Send an email

Use library functions, classes or objects to create a short email addressed to your own email address. The subject should be, "Greetings from langref.org", and the user should be prompted for the message body, and whether to cancel or proceed with sending the email.
perl
#SendSimpleEmail.pl
#
# Uses NET::SMTP to send an email to a specific email address
#Modification History
# 2009-MAR-17: GGARIEPY: [creation] (note: geoff.gariepy@gmail.com)

use strict;
use Net::SMTP; # See http://search.cpan.org/~gbarr/libnet-1.22/Net/SMTP.pm

my $smtpserver = 'some.smtp.server.fqdn.com'; # FQDN of SMTP server
my $fromaddress = 'somebody.surname@someemail.com';# Authorized user of SMTP server
my $subject = 'Greetings from langref.org'; # Subject of the message
my $recipient = 'geoff.gariepy@gmail.com'; # Recipient address
my @now;

# Prompt user for the message body to send
print "Enter the body of the message to send, then press Enter >";
my $message = <STDIN>; # String containing the body of the email

# Prompt user to see if execution should continue
print "Open connection to SMTP server [$smtpserver] to send your message? y/N [N] >";
my $yesorno = <STDIN>;
unless ($yesorno =~ /y/i ) {
print "Aborting send of message\n";
exit;
}


my $smtp = Net::SMTP->new($smtpserver, Debug => 1);# Connect to the SMTP server, and
# output diagnostics to STDOUT (DEBUG mode)

# Check to make sure connection was established; die if not.
if (!ref($smtp)) {
die("SENDMAIL: Couldn't establish session with $smtpserver! Message not sent!\n");
}

# Start the communication with the SMTP server by telling it we want
# to mail something.
$smtp->mail($fromaddress);

# Perl's NET::SMTP interface specifies the recipient(s) of the message by
# calls to the recipient method.
# Note that the method should be called once for each separate recipient
# (set up a loop to do this.)
# We're only going to do it once, however, since we only have one recipient.
$smtp->recipient($recipient);

# Figure out current date/time for the message date stamp
# Date stamp format is DD Monthname YY HH:MM:SS TIMEZONE
my @monthnames = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
@now = gmtime(time);
for (0..$#now) {
# Make single-digit date/time elements two digits
if (length($now[$_]) lt 2) {$now[$_] = '0'.$now[$_];} # (i.e. prefix with '0')
}

# Slice off just the time and date elements we need from the output of gmtime()
my($YY, $MON, $DD, $HH, $MM, $SS) = @now[5,4,3,2,1,0];
$YY += 1900; # gmtime() epoch starts at 1900

my $monthname = $monthnames[$MON]; # Get the name of the month

# Finally build the silly date stamp!
my $datestring = "Date: $DD $monthname $YY $HH:$MM:$SS GMT";

# Tell the SMTP server we're about to send a block of message data
$smtp->data();
$smtp->datasend("$datestring"); # Give it the message date stamp
$smtp->datasend("From: $fromaddress\n"); # Send from address
$smtp->datasend("To: $recipient\n"); # Build the *display* list of 'to:' addresses
$smtp->datasend("Subject: $subject\n\n"); # Send subject delimited by two CRLFs
$smtp->datasend($message); # Send the message body
$smtp->dataend(); # Actually sends the message!!
$smtp->quit(); # Close the link to the SMTP server

__END__