EyeOpener has asked for the wisdom of the Perl Monks concerning the following question:
Quick, maybe dumb question: I've got some text files with lines made up of values separated by a single char. I need to read the lines and split them. The separator char may change between files, so it's defined as a variable in the script.
The problem comes when the separator char is a Perl metacharacter. So, this
works when $char is 'z', but not when $char is '*'.@line = split /$char/, $_;
Quick workaround, anyone?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split on metachar
by saskaqueer (Friar) on Jan 06, 2005 at 01:19 UTC | |
by EyeOpener (Scribe) on Jan 06, 2005 at 17:17 UTC | |
|
Re: Split on metachar
by Eimi Metamorphoumai (Deacon) on Jan 06, 2005 at 01:20 UTC | |
|
Re: Split on metachar
by borisz (Canon) on Jan 06, 2005 at 01:21 UTC | |
|
Re: Split on metachar
by gopalr (Priest) on Jan 06, 2005 at 09:17 UTC |