Help for this page

Select Code to Download


  1. or download this
    while( my $word = <STDIN> ){
      chomp $word;
      last if $word eq 'done';
      $counter{$word}++;
    }
    
  2. or download this
    for my $word (keys %counter){
      print "You typed $word $counter{$word} time" .($counter{$word}>1 ? '
    +s' : ''). ".\n";
      # or
      printf "You typed %s %d time%s.\n", $word, $counter{$word}, ($counte
    +r{$word}>1?'s':'');
    }