use strict; use warnings; sub globify { local $" = ","; my @commas = map qq{"$_"}, split /,/, $_; @commas == 1 ? qq{"$_"} : "{@commas}"; } while (<DATA>) { print glob ( join '|', map {globify} split /\|/ ,$_ ); } __DATA__ some text FOO | some text BAR | oh , no , commas | some text BAZ | som +e text QUX some text FOO | some text BAR | single | some text BAZ | some text QUX
some text FOO | some text BAR | oh | some text BAZ | some text QUX some text FOO | some text BAR | no | some text BAZ | some text QUX some text FOO | some text BAR | commas | some text BAZ | some text QUX some text FOO | some text BAR | single | some text BAZ | some text QUX
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re: splinting a line of text by comma
by LanX
in thread splinting a line of text by comma
by benaw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |