Friday, December 24, 2010

Alpha(bet) Geek


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

No comments: