Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting within a file

by Miguel (Friar)
on Mar 05, 2005 at 21:06 UTC ( #436960=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Sorting within a file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://436960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2015-07-28 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls