in reply to Named Sort Subs with Strict?

The trouble is that you're localizing the variables in one block, then trying to use them in another. Since the variables exist in do_msalist(), they don't exist in by_americentric().

You need to have the variables accessible by by_americentric(). There are a few ways to do this. One way is to put both of the subroutines inside an enclosing block, like this:

{ my (%country, %state, %msaname); sub do_msalist { my @msakeys = @_; foreach(sort by_americentric @msakeys) { #... } } sub by_americentric { $country{$b} cmp $country{$a} or $state{$a} cmp $state{$b} or $msaname{$a} cmp $msaname{$b} or $a <=> $b; } }

Or, you can define the associative arrays as package variables with 'use vars'. Or you can just put by_americentric in as a blockin do_msalist, and call it that way:

sub do_msalist { my @msakeys = @_; foreach(sort { $country{$b} cmp $country{$a} or $state{$a} cmp $state{$b} or $msaname{$a} cmp $msaname{$b} or $a <=> $b; } @msakeys) { #... } }
That'll work if you only call by_americentric right there. But it's harder to read.

stephen