I can replicate your results
with Perl 5.8.8 and Tie::File 0.97 and
with Perl 5.10.0 and Tie::File 0.97_02.
sort is optimized to sort in place when the source and destination are the same.
>perl -MO=Concise -e"@a = sort @a" 2>&1 | find "sort" 7 <@> sort lK/INPLACE ->8 >perl -MO=Concise -e"@b = sort @a" 2>&1 | find "sort" 7 <@> sort lK ->8
I don't know if it's a bug in Tie::File when dealing with sort's optimization or a bug in sort's optimization when dealing with tied arrays, but the bug can be avoided by avoiding the optimization:
@tied_array = map $_, sort { uc($a) cmp uc($b) } @tied_array;
Update: Better yet,
@tied_array = ((), sort {uc($a) cmp uc($b)} @tied_array);
In reply to Re: Tie::File - sorting array adds empty lines
by ikegami
in thread Tie::File - sorting array adds empty lines
by svenXY
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |