fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Data::Dumper;
  5. my %name_degree;
  6. my %name_industry;
  7. while(<DATA>){
  8. if(/^([A-Za-z]+).*?(graduation)/){
  9. $name_degree{$1}++;
  10. }
  11. if(/^([A-Za-z]+).*?(IT industry)/){
  12. $name_industry{$1}++;
  13. }
  14. }
  15. foreach (keys %name_degree){
  16. print "$_ word has $name_degree{$_} Graduations\n";
  17. }
  18. foreach (keys %name_industry){
  19. print "$_ word has $name_industry{$_} IT industry\n";
  20. }
  21. __DATA__
  22. John completed his graduation
  23. John is working for an IT industry
  24. Thomas completed his graduation
  25. John completed his graduation
  26. Thomas is working for an IT industry
  27. Thomas is working for an IT industry
Success #stdin #stdout 0.02s 7248KB
stdin
Standard input is empty
stdout
Thomas word has 1 Graduations
John word has 2 Graduations
John word has 1 IT industry
Thomas word has 2 IT industry