in reply to splinting a line of text by comma
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: splinting a line of text by comma
by tybalt89 (Monsignor) on Nov 23, 2018 at 04:20 UTC | |
by LanX (Saint) on Nov 23, 2018 at 17:02 UTC | |
by tybalt89 (Monsignor) on Nov 26, 2018 at 15:22 UTC | |
by LanX (Saint) on Nov 26, 2018 at 15:27 UTC |