in reply to qw with comma delimiter

Not a favoured construct, but if your data doesn't contain newlines, you could get away with a non-interpolating HERE_DOC.

my @list = split $/, <<'END_OF_LIST'; £$%^&*( £@£@$@^&*£&*@' "$@':>< ;,. . ..^/ END_OF_LIST print join"-|-", @list;

Using single quotes around the label tells perl not to interpolate the contents. Using $/ or "\n" as the split format will do the delimiting and allow, leading, trailing and embedded whitespace, commas, quotes etc. Basically everything except newline.

If you need to embed newlines as well, then your probably into the situation of having to use hand crafted CSV with appropriate quoting and escaping and something like Text::xSV.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Replies are listed 'Best First'.
Re: Re: qw with comma delimiter
by jacques (Priest) on Jul 27, 2003 at 03:14 UTC
    Thanks. That's a nice solution. But how could I use that on the import list? I think I am resigned to going with the q// comma solution and hope for the best.

      You would use it where you could use any list. That includes as arguments to import():

      use Some::Module split( $/, <<'END_IMPORT'); argument #1 second 'argument' joij0986t098$@$*()*%@!~ END_IMPORT