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, ''; }