As a one-liner:
perl -ne '/(\S*)\s+(\S*)/; push @a,$1 if length $1; push @b,$2 if length $2; END{ print "First column output:\n\n@a\n\nSecond column output:\n\n@b\n\n" }'And more readably:
while (<>) { # Added a conditional per merlyn's advice /(\S*)\s+(\S*)/ or next; # /(\S*)\s+(\S*)/; push @a, $1 if length $1; push @b, $2 if length $2; } print "First column output:\n\n@a\n\n", "Second column output:\n\n@b\n\n"
Seeking Green geeks in Minnesota
In reply to Re: making a single column out of a two-column text file
by diotalevi
in thread making a single column out of a two-column text file
by allolex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |