Forum Moderators: coopster & phranque

Message Too Old, No Replies

Escape \n

         

julep821

1:17 am on Jul 20, 2004 (gmt 0)

10+ Year Member



I am reading in a csv file that is then output to another csv file. I am trying to strip out the line breaks within one of the column fields. The section of code I am having a problem with pertains to escaping the line break.

My question is what am I doing wrong in regards to escaping the \n? I keep getting the following error:

#########################################
ERROR MESSAGE
#########################################

Backslash found where operator expected at ports.pl line 291, near "$ports =~ s/\"
(Might be a runaway multi-line // string starting on line 290)
(Missing operator before \?)

#########################################
CODE
#########################################

if ($ports =~ /\.+¦\,+¦;+¦\/+/¦\\n+/) {
$ports =~ s/\.+/ /g;
$ports =~s/\,+/ /g;
$ports =~s/;+/ /g;
$ports =~s/\?+/ /g;
$ports =~s/\/+/ /g;
$ports =~s/\\n+/ /g;
@portarray = split (/ /, $ports);

VectorJ

1:25 am on Jul 20, 2004 (gmt 0)

10+ Year Member



I think your problem is up at the top:

if ($ports =~ /\.+¦\,+¦;+¦\/+/¦\\n+/) {

I don't think that slash (I put it in bold) is supposed to be there.

julep821

1:28 am on Jul 20, 2004 (gmt 0)

10+ Year Member



THanks! That was it :)