Note: The archives category content is an automatically generated focus channel and does not neccessarily reflect the opinions of this blog. No responsibility is taken for the external links presented here, follow at your own discretion.
The archives content is never scraped from sites - but an abstract obtained from search engines.
| Problem |
Solution |
Example |
Reference |
Recommended |
Well here it is in Perl - see example tab. BTW you can always write an awkscript and run it through a2p - very good for learning Perl!
|
|
| Problem |
Solution |
Example |
Reference |
Recommended |
Show column 1: perl -ane 'print $F[0]."\n";' Show column 2: perl -ane 'print $F[1]."\n";' Show last column: perl -ane 'print $F[$#F]."\n";' Show last but one column: perl -ane 'print $F[($#F-1)]."\n";' So you just run your program, or cat your file, etc and pipe it through this code to get specific column.
|
Leave a Reply
June 5th, 2007 at 11:38 pm
Use split:
my @columns = split /\t/, $input;
my $third_column = $columns[2];
June 6th, 2007 at 8:36 pm
[…] Perl Coding School ยป Column handling in Perl (tags: Perl column handling a2p Coding School) […]