in reply to sorting an associated array

We don't call them associative arrays in Perl. They're called hashes.

Hashes are inherently unsorted. You can't sort them. You can however get a list of the keys for the hash, and sort that list. The keys function will give you the keys for a hash; the sort function sorts lists.

my %data = ( c => 3, b => 1, a => 2, ); print "Sorted by key...\n"; for my $key (sort keys %data) { print "$key : $data{$key}\n"; } print "Sorted by value...\n"; for my $key (sort { $data{$a} <=> $data{$b} } keys %data) { print "$key : $data{$key}\n"; }
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name