in reply to Why does 'print shift sort @array' not work?
The problem is that sort @a returns a list, not an array. What you've written is equivalent in syntax to shift (1,2,3). A read of perldata might provide some insight.
Update: In addition to ikegami's solutions below, you can use an anonymous array to make your code work. Pointless use of a shift, though, unless you store the array ref.
@array = ( 4, 1, 3, 2 ); print shift @{[sort @array]}; # Prints 1 print shift @{$sorted_ref = [sort @array]}; # Prints 1 and stores rema +ining values
|
|---|