Re: resolve single line with multiple items into mutliple lines, single items



"ela" <ela@xxxxxxxxxx> wrote:
Old line(columns tab-delimited):

Col1 Col2 Col3 ... Coln
A B1@B2 C ... N1@N2@N3

New lines
A B1 C .. N1
A B1 C .. N2
A B1 C .. N3
A B2 C .. N1
A B2 C .. N2
A B2 C .. N3

The problem is: although pattern matching can recognize "@", but how to
write the code generically so to get all N1, N2 and N3, such that the number
of items aren't known beforehand?

split() line at tab (to get indivudual column), then foreach() column
split() at '@' to get list of individual values.

This automatically leads to a nested loop, which you can use nicely to
print the lines in the desired order.

jue
.