tlm has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks, I need to consult your wisdom. Consider:
To elucidate this puzzle, I consulted the inscrutably wise (though still fallible) -MO=Deparse:use strict; sub do_nothing { @_ } my @in = qw( e n i g m a ); my @out = sort do_nothing( @in ); print "@out\n"; __END__ % perl enigma.pl e n i g m a
So perl is interpreting sort do_nothing( @in ) as sort do_nothing @in, which, given the explicit use of parentheses, seems to me beyond perverse.% perl -MO=Deparse enigma.pl sub do_nothing { use strict 'refs'; @_; } use strict 'refs'; my(@in) = ('e', 'n', 'i', 'g', 'm', 'a'); my(@out) = (sort do_nothing @in); print "@out\n"; __DATA__ enigma.pl syntax OK
Is this a bug or is this a feature?
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perversity of sorts
by Tanktalus (Canon) on Apr 01, 2005 at 03:39 UTC | |
by wolv (Pilgrim) on Apr 05, 2005 at 06:42 UTC | |
|
Re: Perversity of sorts
by Roy Johnson (Monsignor) on Apr 01, 2005 at 01:40 UTC | |
|
Re: Perversity of sorts
by Mugatu (Monk) on Apr 01, 2005 at 00:54 UTC | |
by tlm (Prior) on Apr 01, 2005 at 01:55 UTC | |
|
Re: Perversity of sorts
by shemp (Deacon) on Apr 01, 2005 at 00:22 UTC | |
by tlm (Prior) on Apr 01, 2005 at 00:28 UTC |