#!/perl/bin/perl # # use.pl -- statistics for 'use' module name. use strict; use warnings; use diagnostics; my %module; my @list; while () { if (/^use\s(.*?);/) { my $what = $1; if ($what =~ /^lib/) { $module{'lib'}++; } elsif ($what =~ /^constant/) { $module{'constant'}++; } else { $module{$what}++; } } } for (keys %module) { push(@list,sprintf("%04d|%s",$module{$_},$_)); } for (sort @list) { my($howmany,$what) = split /\|/; print "$howmany, $what\n"; } __DATA__