in reply to Parsing a table with variable columns on each line

Here's another way to solve your problem.
#!/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
    Now available with more punctuation variables:

    #!/usr/bin/perl -l use strict; while( <> ) { chomp; local $, = "\t"; my ($name, $val1, $val2, @val3) = split ( "\t" ); print $name, $val1, $val2, $_ for @val3; }

    Update: Edited because I apparently didn't understand the original question. The point of setting $, instead of using join remains.
      Thank you. Job is done now.