in reply to How to switch off the autosplit ?
But your example is unclear, because it looks like you just want to stop doing whatever you were doing when the first value on a line happens to equal 0 (so why not just exit at that point?) Anyway, here's another way to do it:
I would expect that you would normally be putting something in that "else" block involving $_ ...perl -ane 'BEGIN{$auto=1} $auto=0 if($F[0]==0); if($auto){print @F[0.. +2]} else{ }'
If it's a question of "optimizing" (saving perl from doing all that work on splitting lines), then avoiding "-a" as suggested in the first reply will be the way to go. But usually, optimization is not much of an issue in one-liners like this.
|
|---|