ZWcarp has asked for the wisdom of the Perl Monks concerning the following question:
Say I have a file with 30 columns and I want to add 1 to the number in column 15, but otherwise print the line as is. Is there a better way to do this then something like
perl -lane' print "$F[0]\t$F[2]\t$F[3]....\t" .$F[15]+1 . "\t$F[16] .....\t$F[30]"' file.txtThe dots representing $Fx\t ( or everything in-between) Any ideas? the shorter the better. Also i was thinking maybe a tricky substation might work but this could get difficult with more complex operations. Still.... open to any suggestions Thanks for your time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Editing just one column in a file
by BrowserUk (Patriarch) on Nov 28, 2011 at 21:54 UTC | |
by ZWcarp (Beadle) on Nov 28, 2011 at 22:14 UTC | |
by vinian (Beadle) on Nov 29, 2011 at 02:04 UTC | |
by BrowserUk (Patriarch) on Nov 29, 2011 at 02:35 UTC | |
by ZWcarp (Beadle) on Nov 30, 2011 at 20:23 UTC | |
by BrowserUk (Patriarch) on Nov 30, 2011 at 21:12 UTC | |
by vinian (Beadle) on Nov 29, 2011 at 09:00 UTC | |
by choroba (Cardinal) on Nov 29, 2011 at 10:13 UTC | |
by Tux (Canon) on Dec 01, 2011 at 07:35 UTC | |
|