Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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!


#!/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 = ""; # 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\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";

In reply to The Spudgun by MrCromeDome

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (3)
    As of 2021-03-05 01:46 GMT
    Find Nodes?
      Voting Booth?
      My favorite kind of desktop background is:

      Results (108 votes). Check out past polls.