Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex Word Pairs

by goibhniu (Hermit)
on Aug 16, 2007 at 00:41 UTC ( [id://632894]=note: print w/replies, xml ) Need Help??


in reply to Regex Word Pairs

For my cryptography hobby (old school cryptograms, not modern cypto), I wrote this to find frequencies of letter pairs. I don't know if it could be adapted.

# # # my $input = shift; # my $input = "peon bookkeeper"; my $input; #print $input."\n"; while (<>) { $input = $_; @evenmatches = ($input =~ m/ (.{2}?) (?{ #print $^N . " found at " . ($tmpp +os = pos($input)) . "\n"; $chars{$^N}++; }) /xg); #print join(", ", @evenmatches)."\n"; #print $#evenmatches + 1 ." matches found\n"; #print $input."\n"; pos($input) = 1; @oddmatches = ($input =~ m/ (.{2}?) (?{ #print $^N . " found at " . ($tmpp +os = pos($input)) . "\n"; $chars{$^N}++; }) /xg); #print join(", ", @oddmatches)."\n"; #print $#oddmatches + 1 ." matches found\n"; } print "frequency of '$_' is $chars{$_}\n" foreach (sort {$chars{$b} <=> $chars{$a}} keys %chars); print "\n"; print "frequency of '$_' is $chars{$_}\n" foreach (sort keys %chars);


I humbly seek wisdom.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://632894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-20 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found