in reply to split and sort functions

It sounds like you want to do
my $str = "this,ok,that,cool,free,dom"; for my $key (sort keys (%hash = split /,/, $str)) { ... }
which probably isn't allowed (you probably get an error message like "argument to keys must be hash, not list assignment"). Long story short, to get this done, you'd have to do something sneaky like:
for my $key (sort keys %{ $hashref = { split /,/, $str } }) { ... }
or
for my $key (sort keys %{ +{%hash = split /,/, $str} }) { ... }
But that's a bit of kludge for something that should really be two distinct processes. Unless you don't really need the hash, in which case you can just do:
for my $pair (sort($str =~ /([^,]*,[^,]*)(?:,|$)/g)) { my ($k, $v) = split /,/, $pair; ... }

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart