From: Felix Geerinckx <[EMAIL PROTECTED]>
> Using your datastructure, this would indeed be rather complicated. If
> you could use the datastructure I proposed at the beginning of this
> post, you could write
I don't think it's wise to overwrite a function definition over an
over again. Create an unnamed function:
> sub sortit {
> my $array = shift;
> my $code = 'sub sortfun { ';
my $code = 'sub { ';
> my $first = 1;
>
> while (@_) {
> my $s = shift;
> my $d = shift;
> $code .= ' || ' unless $first;
> $first = 0;
> $code .= $d eq 'A' ?
> "\$a->{$s} cmp \$b->{$s}" :
> "\$b->{$s} cmp \$a->{$s}" ;
> }
> $code .= '}';
> undef &sortfun;
> eval $code;
> my @result = sort sortfun @$array;
The last three lines become:
my $sortfun = eval $code;
my @result = sort $sortfun @$array;
> return \@result;
> }
This may be combined with the code I posted. So then you get what you
are after.
Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]