Re: resolve single line with multiple items into mutliple lines, single items
- From: Jürgen Exner <jurgenex@xxxxxxxxxxx>
- Date: Sun, 05 Apr 2009 09:09:33 -0700
"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
.
- Follow-Ups:
- References:
- Prev by Date: Re: check file exists with case sensitive on a case insensitive file system
- Next by Date: Re: resolve single line with multiple items into mutliple lines, single items
- Previous by thread: Re: resolve single line with multiple items into mutliple lines, single items
- Next by thread: Re: resolve single line with multiple items into mutliple lines, single items
- Index(es):