Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Reorganizing Columns with Perl One Liner

by johngg (Canon)
on Nov 25, 2011 at 14:18 UTC ( [id://940078]=note: print w/replies, xml ) Need Help??


in reply to Reorganizing Columns with Perl One Liner

Something along these lines perhaps?

knoppix@Microknoppix:~$ perl -Mstrict -wE ' > open my $inFH, q{<}, \ <<EOD or die $!; > foo r1.1 abc > foo r10.1 pqr > qux r2.1 lmn > bar r33.1 xpq > EOD > > printf qq{%-6s%-4s%-s\n}, ( split )[ 1, 0, 2 ] > for <$inFH>;' r1.1 foo abc r10.1 foo pqr r2.1 qux lmn r33.1 bar xpq knoppix@Microknoppix:~$

You would need to tweak this a bit for extra fields and might have to take the approach of generating the printf format progammatically.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-16 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found