Hi,
thanks for your reply,
Stas Bekman wrote:
> On Wed, 20 Dec 2000, Alexander Farber (EED) wrote:
> >
> > sub mysort
> > {
> > my $param = $query -> param ('sort') || 'MHO'; # XXX global $query,
> > # not mod_perl clean?
> > return $a -> {$param} cmp $b -> {$param};
> > }
> >
> > This subroutine is called later as:
> >
> > for my $href (sort mysort values %$hohref)
> > {
> > ...
> > }
>
> Your code is better written as:
>
> my $param = $query->param('sort') || 'MHO';
> for my $href (sort {$a->{$param} cmp $b->{$param}} values %$hohref) { }
but isn't it the same? The anonymous sub {$a->{$param} cmp $b->{$param}}
uses the "outside"-variable $param.
> why wasting resources...
Also, assuming I would like to have a separate sorting subroutine
mysort, since it is mopre complicated as listed above... How would
you pass some parameters to this subroutine? Via global vars?
Regards
Alex