Thank you all for your wonderful suggestions. I'm going to try following Perlbotics' suggestions regarding md5ing the pairs and storing that. If that doesn't work (either people complain that this info is on my machine or someone actually bothers to try to crack it), I'll follow BrowserUK's suggestion. The local third party approach mr_mischief suggests is clearly unacceptable, as everyone here is quite fond of presents. And of course, I'm tempted to try Fletch's solution just because. I mean, damn.

For those who are interested, I've included my final source. There's support for mr_mischief's third party by storing an email address in $authority. Of course, the e-mail credentials file is for a Santa-only account and is chmodded to 600.

#!/usr/bin/perl -w use strict; use List::Util qw(shuffle); use Digest::MD5 qw(md5_hex); use Net::SMTP::TLS; # Parameters my $authority = ''; my $value = 10; my $participantsFile = 'santaList.txt'; # Name#email\n my $previousFile = 'lastYear.txt'; # sorted md5 hashes\n my $serverInfoFile = 'emailCredentials.dat'; # Declare variables with file-wide scope my (%emails, @names, %matching, @previous, @content); # Initialize data open INPUT, '<' . $participantsFile; while (<INPUT>) { chomp; my ($name,$email) = split '#'; $emails{$name} = $email; } close INPUT; open INPUT, '<' . $previousFile; while (<INPUT>) { chomp; push @previous,$_; } close INPUT; # Generate the list @names = keys(%emails); # Collect the list of all participants GENERATE: while (1) { # Picking loop @matching{@names} = shuffle(@names); # Match 'em up # No one has themselves foreach (@names) { next GENERATE if $_ eq $matching{$_}; } # Generate digests for comparison my @digest = (); foreach (@names) { push @digest, md5_hex($_, '=>', $matching{$_}); } @digest = sort @digest; # Compare against previous year's results my $index = 0; foreach (@digest) { while ($index < @previous and $_ gt $previous[$index]) {$index +++} last if $index == @previous; next GENERATE if $_ eq $previous[$index]; } #Passes - store the digests for next year open OUTPUT, '>' . $previousFile; print OUTPUT join "\n", @digest; close OUTPUT; last GENERATE; # Passes } # E-mail the results { open INPUT, '<' . $serverInfoFile; my $host = <INPUT>; chomp $host; my $port = <INPUT>; chomp $port; my $user = <INPUT>; chomp $user; my $password = <INPUT>; chomp $password; close INPUT; my $server = Net::SMTP::TLS->new( $host, Port => $port, User => $user, Password=> $password, ) or die "Can't open mail connection: $!"; # Independent auditor if ($authority) { @content = (); $content[0] = "The picks for this year\'s gifting are as follo +ws\:"; foreach (@names) { push @content, "$_ is giving to $matching{$_}"; } send_mail($server, $authority, $user, 'Secret Santa Drawing', +@content); } foreach (@names) { @content = (); $content[0] = "Dear $_\,"; $content[1] = ""; $content[2] = "Thank you for participating in this year\'s Sec +ret"; $content[3] = "Santa gift exchange\. This year\, you will be +giving"; $content[4] = "a gift to $matching{$_}\. Please remember to l +imit the"; $content[5] = "monetary value of any gift you give to \$$value +\."; $content[6] = ""; $content[7] = "Happy Holidays\,"; $content[6] = "Robo-Santa 5000"; send_mail($server, $emails{$_}, $user, 'Secret Santa Drawing', + @content); } $server->quit; } sub send_mail { my($server, $to, $from, $subject, @body) = @_; $server->mail($from); $server->to($to); $server->data(); $server->datasend("To: $to\n"); $server->datasend("From: $from\n"); $server->datasend("Subject: $subject\n"); $server->datasend("\n"); foreach (@body) { $server->datasend("$_\n"); } $server->dataend(); }

In reply to Re: Temporarily Obscuring a Lottery Draw by kennethk
in thread Temporarily Obscuring a Lottery Draw by kennethk

Title:
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, details, 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, summary, 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.