in reply to How to get correct regex
use warnings; use strict; while (<DATA>) { chomp; my @cols = split /\s+/, $_, 6; print "@cols[1,3,5]\n"; } __DATA__ 1 F 14 0.06 OPEN 2 F 216 0.97 CONTACT 4 F 326 1.47 LEFT 5 F 232 1.05 MID 6 F 54 0.24 RIGHT 7 F 6 0.03 AT 8 F 6 0.03 AT_GHT 11 F 184 0.83 5DBLT 12 F 151 0.68 2P5D 21 P 21009 94.64 Bin P
Outputs:
1 14 OPEN 2 216 CONTACT 4 326 LEFT 5 232 MID 6 54 RIGHT 7 6 AT 8 6 AT_GHT 11 184 5DBLT 12 151 2P5D 21 21009 Bin P
See also unpack if fixed width applies.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get correct regex
by Anonymous Monk on Jan 13, 2015 at 13:46 UTC | |
by BillKSmith (Monsignor) on Jan 14, 2015 at 14:17 UTC | |
by AtlasFlame (Novice) on Jan 15, 2015 at 11:32 UTC | |
|
Re^2: How to get correct regex
by AtlasFlame (Novice) on Jan 13, 2015 at 13:29 UTC | |
by AnomalousMonk (Archbishop) on Jan 13, 2015 at 18:45 UTC |