pat_mc has asked for the wisdom of the Perl Monks concerning the following question:
which the interpreter rejected with the complaintprint shift sort @array;
However, the following does work as desired:Type of arg 1 to shift must be array (not sort) at script.pl line 7, n +ear "@array;"
my @a = ( 4, 1, 3, 2 ); my @b = sort @a; print shift @b;
1. sort @a returns an array, namely the sorted version of @a. 2. shift takes an array as argument and returns a scalar.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does 'print shift sort @array' not work?
by kennethk (Abbot) on Feb 26, 2009 at 18:59 UTC | |
|
Re: Why does 'print shift sort @array' not work?
by ikegami (Patriarch) on Feb 26, 2009 at 19:04 UTC | |
|
Re: Why does 'print shift sort @array' not work?
by almut (Canon) on Feb 26, 2009 at 19:03 UTC | |
by pat_mc (Pilgrim) on Mar 12, 2009 at 21:00 UTC | |
|
Re: Why does 'print shift sort @array' not work?
by hbm (Hermit) on Feb 26, 2009 at 19:18 UTC | |
by ikegami (Patriarch) on Feb 26, 2009 at 19:28 UTC | |
by hbm (Hermit) on Feb 26, 2009 at 20:19 UTC | |
by ikegami (Patriarch) on Feb 26, 2009 at 20:28 UTC | |
by Fletch (Bishop) on Feb 26, 2009 at 20:30 UTC | |
by ikegami (Patriarch) on Feb 26, 2009 at 20:32 UTC | |
by Fletch (Bishop) on Feb 26, 2009 at 20:40 UTC | |
by hbm (Hermit) on Feb 26, 2009 at 21:07 UTC | |
| |
|