in reply to Bug in Sort::Fields?
in thread Split(), Initial Spaces, & a limit?
# 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bug in Sort::Fields?
by cmv (Chaplain) on Jul 20, 2010 at 18:39 UTC | |
by ikegami (Patriarch) on Jul 20, 2010 at 19:02 UTC | |
by cmv (Chaplain) on Jul 20, 2010 at 19:14 UTC | |
by ikegami (Patriarch) on Jul 20, 2010 at 19:17 UTC | |
by ikegami (Patriarch) on Jul 20, 2010 at 19:28 UTC | |
by cmv (Chaplain) on Jul 20, 2010 at 19:41 UTC | |
|