Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: read column in perl

by jmcnamara (Monsignor)
on Mar 08, 2005 at 09:09 UTC ( [id://437458]=note: print w/replies, xml ) Need Help??


in reply to read column in perl


Here is a one-liner for a Unix system:
$ paste file1 file2 | perl -lane 'print "@F[1,0,2,3]"' 1 a 6 11 2 b 7 12 3 c 7 13 4 d 8 14 5 e 9 23
Or this:
$ paste file1 file2 | awk '{print $2, $1, $3, $4}'

You can change the field separator in either example to suit.

--
John.

Replies are listed 'Best First'.
Re^2: read column in perl
by DentArthurDent (Monk) on Mar 08, 2005 at 12:54 UTC
    I wish I could ++ that 5 times. It showed me a new UNIX command, and the perl arguements at the same time. Great work!

    ----
    My mission: To boldy split infinitives that have never been split before!

      I like to remind people that Unix isn't there just to bootstrap perl. ;-)

      --
      John.

        It isn't??? Oh, well, I suppose sendmail is a useful function too...


        --
        Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0
        perl -e 'print(map(chr,(0x4a,0x41,0x50,0x48,0xa)))'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found