Chas. Owens wrote:
On Sat, Aug 29, 2009 at 11:44, Peter Daum<gator...@yahoo.de> wrote:
I'm struggling with a tricky quoting problem:
I need to split lines divided by some delimiter;
- The delimiter usually will be '|',
but can be changed, so it needs to be variable.
- Furthermore, the columns may also contain the delimiter,
in which case it is quoted by a backslash
snip
The quotemeta function is the right way to go, in that case I am
invoking it using the \Q, \E special escapes:
Oh, I didn't think of these - I separately constructed a string
to which I then applied the qr//, always ending up with the
wrong # of "\" at some place ;-)
However, it still has a bug (as demonstrated by the second data line):
escaped \ does not behave correctly. If you need that functionality
you will probably want to write a simple parser:
... in my case I am dealing with files without any formal specification;
should I ever encounter an escaped escape, I'll reconsider it, but for
the moment that's good enough.
Thanks a lot!
Regards,
Peter
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/