http://www.perlmonks.org?node_id=436960


in reply to Sorting within a file

Yet another way, using IO::All and unpack, as your Data looks fixed length delimited:
#!/usr/bin/perl -w use strict; use IO::All; my @AoA; push @AoA, [ unpack("A7 A8",$_) ] foreach io("file.txt")->getlines; foreach ( sort { $a->[0] <=> $b->[0] } @AoA ) { $_->[1] =~s/^ //; print $_->[0], " ", $_->[1],"\n" }

Miguel