in reply to Dumb problem with dumper.

You appear to be using the $result variable for two separate purposes; here as an array of arrays:

$result[$i][$j]

and here as a hash of hashes

$result->{$j}->{$wrd}++

Make up your mind! Short of some freaky overload magic, that's not likely to work.

Meh. The first is, of course, @result. Either way, the rest of my advice still stands...

I'd strongly recommend you use strict; near the top of your script. (In particular, it's the vars feature of strict that you want, but might as well enable the whole strict pragma.) This will force you to declare the variables you use; and thus encourage you to get them straight in your own head.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'