Friday, December 24, 2010

Alpha(bet) Geek


#/usr/bin/perl
use strict;
use warnings;
my $str = $ARGV[0];
my @alpha_arr = ('a' .. 'z');
my %str_tok_hash = map { lc($_) => undef } 
                   grep { /[a-z]/i } 
                   split(//, $str);
my @diff = grep { not exists $str_tok_hash{$_} } @alpha_arr;
$str = "'The string ($str) contains all the letters of the alphabet";
$str .= " except (".join(' ', sort @diff).").' - contains all the letters"; 
$str .= " of the alphabet. :)";
print "$str\n";

No comments: