ttdsuen has asked for the wisdom of the Perl Monks concerning the following question:
And it fails complaining some scope::$a,$b not defined (with my). The question is, how can I make this work? How can Perl's sort avoid this kind of problems? Daniel.package Foo; ... sub sort(&) { my $self = shift; my $code = \&{shift @_}; sort $code @{$self->{arrayref}}; } my $foo = Foo->new; ... $foo->sort({ lc($a) cmp lc($b) });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: relaying sort's code block
by ikegami (Patriarch) on Aug 18, 2014 at 22:21 UTC | |
|
Re: relaying sort's code block
by tobyink (Canon) on Aug 18, 2014 at 22:15 UTC | |
|
Re: relaying sort's code block
by Laurent_R (Canon) on Aug 19, 2014 at 06:47 UTC |