in reply to Parsing a table with variable columns on each line
#!/usr/bin/perl use strict; while( <DATA> ) { chomp; my ($name, $val1, $val2, @val3) = split ( "\t" ); print join( "\t", ($name, $val1, $val2, $val3[$_]) ) , "\n" for (0 .. $#val3); } __DATA__ Apples 0.5 -10 Emma:17:15:14:18 Peter:2:7:4:1(Newline) Pears 0.7 -12 Alex:101:144:110:111(Newline) Oranges__0.8 -14 Shan:12:14:9:57 Heena:65:17:15:24 Rachel +:1:5:18:54(Newline)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a table with variable columns on each line
by kikuchiyo (Hermit) on Oct 23, 2009 at 19:56 UTC | |
by Anonymous Monk on Oct 26, 2009 at 13:52 UTC |