in reply to A problem with using the split command

You have to double up the backslashes:
perl -e " print join(', ',split(/\\\\/,'\foo\foo1\foo2'))" , foo, foo1, foo2
Update: Note to people downvoting me: Unlike some who posted before me, I tried my solution before posting. (See above: it works).

Replies are listed 'Best First'.
Re: Re: A problem with using the split command
by TASdvlper (Monk) on Apr 30, 2004 at 20:36 UTC
    I got this working on the command line like you have in your example, and it works, but in my script it's still not working. Very strange
      I got this working on the command line ... but in my script it's still not working

      I'm not positive, but I'd say the shell is eating one pair of backslashes. Basically, the shell sees \\\\, passes it in to perl as \\, which gets passed into the RE engine as \. Welcome to the backwhack hell that is multiple layers of interpolation. :)

      So, in summary, \\\\ on the shell should be \\ in your script.