Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Thursday February 21, 2008
09:12 PM

Winter Scripting Games

[ #35719 ]

I decided to enter the 2008 Winter Scripting Games. I managed to get full points for the first event but screwed up and didn't notice the deadline for the second.
Here's my entry for the first. It seems a bit simpler than Jan's solution and avoids an eval. I'll try to do a better job with commentary for the latter events.

#!/usr/bin/perl -w
use strict;

print "Enter phone number: ";
chomp(my $phone = <STDIN>);

my %letters;
{
    my @L = ('A' .. 'P', 'R' .. 'Y');
    my $n = 2;
    while (my @t = splice @L, 0 => 3) {
        $letters{$n++} = sprintf '[%s%s%s]', @t;
    }
}

my $match = '^' . join('', map $letters{$_}, split //, $phone) . '$';

open my $in, '<c:/Scripts/WordList.txt'
    or die "Can't read wordlist: $!\n";
while (<$in>) {
    tr/a-z/A-Z/;
    if (/$match/o) { print; last }
}
close $in;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.