# Initial spaces in column 1 don't sort the same as...
It's impossible for a column to have initial spaces when spaces is your delimiter. The first field of most of @data is "".
use strict; use warnings; use Sort::Fields; use Data::Dumper; my @data = ( " 56 1752.eps", " 56 2613.eps", " 56 3469.eps", " 8 INPUT000", " 16 INPUT001", " 16 INPUT002", " 96 MTA.1.ps", " 96 MTA.6.ps", " 80 MTA.7.ps", " 32 head.eps", " 8 labs", " 0 lib", " 8 mkexe.bat", " 112 out", " 0 screenshots", "8720 trace.exe", " 16 trace.pl", " 8 tracehosts", "1160 trace.041409.exe", "1160 trace.orig.exe", ); s/^\s+// for @data; my @sorted = fieldsort( ['1n'], @data); print(Dumper(\@sorted));
By the way, you were using grep as map, and you were clobbering @data in the process.
In reply to Re: Bug in Sort::Fields?
by ikegami
in thread Split(), Initial Spaces, & a limit?
by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |