#!/usr/local/bin/perl5 -w # # Paul Garrett, 31 Oct 1998 # # for crypto: find letter patterns via regexp at command line # in file named at command line # # usage: $0 # $regexp = $ARGV[0]; chomp($regexp); $file = $ARGV[1]; chomp($file); open(H, "<$file") || die "Can't open $file:$!\n"; %record = (); while () { while (/$regexp/) { $_ = $'; $frag = $&; if ( defined %record -> {$frag} ) { %record -> {$frag}++; } else { %record -> {$frag} = 1; } } } close H; foreach $key (sort keys %record) { print "\"$key\" occurs ", %record -> {$key}, " times\n"; } ######################################################################