[JaxPM] regex weirdness
j proctor
jproctor at oit.umass.edu
Thu Jul 12 10:39:35 CDT 2001
On the jacksonville-pm-list; Jax.PM'er j proctor <jproctor at oit.umass.edu> wrote -
I want to sort a list based on the number of Zs each element has in it,
and I don't have a Cookbook handy.
Code like this doesn't work:
@out = sort {
(scalar @{[$a =~ /Z/g]}) <=> (scalar @{[$b =~ /Z/g]})
} @in;
But code like this does:
@out = sort {
zcount($a) <=> zcount($b)
} @in;
sub zcount {
scalar @{[ $_[0] =~ /Z/g ]};
}
I don't really mind the second, because it looks a little cleaner.
Any ideas why it seems to be *required*, though?
Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...
More information about the Jacksonville-pm
mailing list