in reply to split and sort functions
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:my $str = "this,ok,that,cool,free,dom"; for my $key (sort keys (%hash = split /,/, $str)) { ... }
orfor my $key (sort keys %{ $hashref = { 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 $key (sort keys %{ +{%hash = split /,/, $str} }) { ... }
for my $pair (sort($str =~ /([^,]*,[^,]*)(?:,|$)/g)) { my ($k, $v) = split /,/, $pair; ... }
|
|---|