http://www.perlmonks.org?node_id=182184

Ladies, gentlemen, and others, today I (proudly?) introduce you to the first invention produced by Jason's Laboratory of Useless Perl Things. . . the Spudgun!

You'll laugh, you'll cry, or perhaps even hurl at this most wonderous (?) thing. Use it to annoy your spouse, boss, coworkers, family, and friends. All you have to do is pass the Spudgun your e-mail address, your name, the e-mail address of your victim, and the name of your victim, and the Spudgun will do the rest! Having a boring workday? You can even spud yourself!

All that peppy mumbo-jumbo aside. . . this is actually the Perl adaptation of a C-program I wrote some time ago to illustrate some of the cool things that can be done programatically with strings. Once I wrote it in C, the Spudgun seemed potentially far more beautiful thing in Perl, and so I ported it.

Replace $smtp with the name (or IP) of the mailserver that you want to use to send the Spudgun output. You can tweak $max_spuds and $rand_max to your preference. . . raise the number of spuds though and you can really tick off some of your loved ones ;) @how, @where, and @what can also be added to. . . In fact, if anyone comes up with some clever ones that I missed, I'd be interested in hearing them =)

For your spudding convenience, I wrapped some CGI code around this and posted the result to here for you to play with.

Thank you for letting me waste your time ;) Happy spudding to you!

MrCromeDome

#!/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 hea +d 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 t +o you!\n";