in reply to A problem with using the split command

Single quotes or double quotes, I can get it to work with 'four' slashes. See below
>echo $perlcode $a="x\\y\\z";@b=split('\\\\',$a);print join(";",@b),"\n" >perl -e "$perlcode" x;y;z
or
>echo $perlcode $a="x\\y\\z";@b=split("\\\\",$a);print join(";",@b),"\n" >perl -e "$perlcode" x;y;z
I would have thought that if 4 back-slashes would work with double quotes (becoming \\ instead), then 2 back-slashes would work with single quotes.

Maybe some wise monk would enlighten us?

Sandy

Replies are listed 'Best First'.
Re: Re: A problem with using the split command
by ysth (Canon) on Apr 30, 2004 at 21:11 UTC
    Single quoted type strings do treat \\ and \ followed by the ending delimiter character as special, just as double quoted strings do. It's everything else that they don't treat specially.
      Ah HA!

      Thanks.