fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my @words = <DATA> =~ /(\w+)/g;
  5. my %seen;
  6. my $count = 1;
  7. foreach my $value (@words) {
  8. if ( !$seen{$value} ) {
  9. print "$count.$value ";
  10. $seen{$value} = 1;
  11. }
  12. else{
  13. print "$value";
  14. }
  15. $count++;
  16. }
  17. __DATA__
  18. He wakes up. He sees the sun rise. He brushes his teeth are white He puts on his clothes. His shirt is blue. His shoes are yellow. His pants are brown. He goes downstairs. He gets a bowl. He pours some milk and cereal. He eats. He gets the newspaper. He reads.
Success #stdin #stdout 0s 6188KB
stdin
Standard input is empty
stdout
1.He 2.wakes 3.up He5.sees 6.the 7.sun 8.rise He10.brushes 11.his 12.teeth 13.are 14.white He16.puts 17.on his19.clothes 20.His 21.shirt 22.is 23.blue His25.shoes are27.yellow His29.pants are31.brown He33.goes 34.downstairs He36.gets 37.a 38.bowl He40.pours 41.some 42.milk 43.and 44.cereal He46.eats Hegetsthe50.newspaper He52.reads