#!/usr/local/bin/perl # Jaime Prilusky, 2009 # an example for hash use $|++; # this is the directory where we have the files to scan # the files we want end on '.express' my $dir = $ARGV[0] || "/home/students/sources/ass4_sources/"; # we will store tissue's name and count in a hash my %data; foreach my $f (glob("$dir/*express")) { print "Found: $f\n"; local(*IN); open(IN,$f); while (my $l = ) { chomp($l); # the line has the format '16. colon', so we split on '. ' # see __DATA__ for a sample content (undef,$tissue) = split(/\.\s+/,$l); next if ($tissue eq ''); $tissue = uc($tissue); $data{$tissue}++; } close(IN); } # show now what tissues we found foreach $k (sort keys %data) { printf ("%-15s %3d\n",$k,$data{$k}); } __DATA__ ADH2 1. Adrenal gland 2. Aorta 3. Breast 4. Germ Cell 5. Kidney 6. Liver 7. Lung 8. Muscle 9. Pancreas 10. Prostate 11. Smooth muscle 12. Stomach 13. Testis 14. Whole embryo 15. breast 16. colon 17. heart 18. liver 19. lung