Advertisement
Guest User

DC badge phrase hint attempt

a guest
Aug 10th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.34 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3.  
  4. my $word_freq = {};
  5. my $space_freq = {};
  6. my $word_space = {};
  7.  
  8. #my $trans = {};
  9. #$trans{} = '';
  10.  
  11. while (<>) {
  12.   m/^(\s*)(.*)$/;
  13.   my $spaces = $1;
  14.   my $word = $2;
  15.   my $space_length = length($1);
  16.  
  17.   #$_ = chr($space_length + 64);
  18.   #y/A-Za-z/N-ZA-Mn-za-m/;
  19.   print $space_length / 2;
  20.   print " ";
  21.  
  22.   if(!exists $word_space->{$word}) {
  23.     $word_space->{$word} = {};
  24.   }
  25.  
  26.   if(!exists $word_space->{$word}->{$space_length}) {
  27.     $word_space->{$word}->{$space_length} = 0;
  28.   }
  29.  
  30.   $word_space->{$word}->{$space_length}++;
  31.  
  32.   if (exists $space_freq->{$space_length}) {
  33.     $space_freq->{$space_length}++;
  34.     #print "increment space count: $space_length\n";
  35.   }
  36.   else {
  37.     $space_freq->{$space_length} = 1;
  38.     #print "declare new space count: $space_length\n";
  39.   }
  40.  
  41.   if(exists $word_freq->{$word}) {
  42.     $word_freq->{$word}++;
  43.   }
  44.   else {
  45.     $word_freq->{$word} = 1;
  46.   }
  47. }
  48.  
  49.  
  50.  
  51.  
  52. for(keys %$space_freq) {
  53.   print $_ . ": " . $space_freq->{$_} . "\n";
  54. }
  55. print "\n\n";
  56.  
  57. for(keys %$word_freq) {
  58.   print $_ . ": " . $word_freq->{$_} . "\n";
  59. }
  60. print "\n\n";
  61.  
  62. for(keys %$word_space) {
  63.   my $word = $_;
  64.   print "$word:\n";
  65.   for(keys %$word_space->{$word}) {
  66.     my $spaces = $_;
  67.     print "  $spaces: " . $word_space->{$word}->{$spaces} . "\n";
  68.   }
  69.   #for(keys %word_space{$_})
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement