#!/usr/bin/perl use strict; use warnings; use Mail::Sender; use Email::Valid; # Get some parameters my ($from_email, $from_name, $to_email, $to_name) = @ARGV; # Die if we don't have valid e-mail addresses die "From e-mail is not a valid address!" unless Email::Valid->address($from_email); die "To e-mail is not a valid address!" unless Email::Valid->address($to_email); # SMTP server my $smtp = "your.mailserver.com"; # Spud settings my $max_spuds = 50; my $rand_max = 60000; my @how = qw(smashed shot bopped hit splattered slammed nailed creamed bonked smacked clobbered); my @where = qw(face hand thumb arm gut eye leg chin gut butt skull head ass groin nads boob ear toe foot); my @what = ("a potato", "a flying spud", "a high velocity spud", "a rocketing potato", "a deadly spud", "a potato of death", "the Mother of All Potatoes", "a hot potato", "a sweet potato"); # What message are we sending? my $message = "$to_name, $from_name has just shot you with a spudgun!!!\n\n"; # Seed the random number generator srand($$|time); # Fire in the hole! my $times = 1 + rand($rand_max) % $max_spuds; for(my $which = 1; $which <= $times; $which++) { $message .= sprintf("You get %s in the %s by %s.\n", $how[rand($rand_max) % (scalar @how)], $where[rand($rand_max) % (scalar @where)], $what[rand($rand_max) % (scalar @what)]); } $message .= "\nYour friend,\nMrCromeDome at perlmonks.org\n"; # E-mail the damage (new Mail::Sender)->MailMsg( { smtp => $smtp, from => $from_email, to => $to_email, subject => "You've just been spudded!", msg => $message }); # Generate a response message print "Thank you, $from_name, for using the spudgun. Happy spudding to you!\n";