Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: tabular format of data

by deepak_4682us (Initiate)
on Feb 18, 2012 at 01:14 UTC ( [id://954660]=note: print w/replies, xml ) Need Help??


in reply to Re^3: tabular format of data
in thread tabular format of data

A.txt:- A:B C:D code: # it has column1 values of txt file @a1=`cut -d":" -f1 < A.txt; # it has column2 values of txt file @a2=`cut -d":" -f2 < A.txt; I wanted to reprent the values in tabular form

Replies are listed 'Best First'.
Re^5: tabular format of data
by Anonymous Monk on Feb 18, 2012 at 01:30 UTC

    eew , you're shelling out for cut

    Here is a oneliner

    perl -F: -lane " print qq/-------/ if 1==$.; print join q/|/, @F, qq// +; print q/--/ x @F, qq//; " < infile > outfile

    more verbosely written as

    BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; our(@F) = split(/:/, $_, 0); print '-------' if 1 == $.; print join('|', @F, ''); print '--' x @F, ''; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-19 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found