I'm having problems with the caret character (^). I'm running a program called sarad (a server application for accessing the British National Corpus) and am communicating with this via a perl filehandle/tcp socket:
$fh=&createSaradSock();
sub createSaradSock {
#Socket stuff
$iaddr = inet_aton($remote);
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
socket(S, PF_INET, SOCK_STREAM, $proto) || bark("$!");
connect(S, $paddr) || bark("$!");
#sara needs NULL terminated strings
$null= "\000";
#unbuffer the socket & define NULL as linefeed
$currentHandle = select(S);
$|=1;
$/=$null;
select($currentHandle);
# ask for code page 850 (sets charset to WINDOWS ANSI)
$query="INFO 850$null";
print S $query;
$response = <S>;
$response=~m/OK/ or bark("$response");
# logging into sarad server
$query="LOG $username $password$null";
print S $query;
$response = <S>;
$response=~m/OK/ or bark("$response");
return \*S;
}
The problem occurs when I want to send the following command to the server:
SOLVE hq000001 ^"strike=VERB"
here's the corresponding code out of the script:
$query='SOLVE ' . $qName . ' ^"strike=VERB"' . $null;
print $fh $query;
$response = <$fh> or saySorry2();
But this doesn't work. It just doesn't return anything and saySorry2() is executed. When I run SOLVE from the shell, I get the message "broken pipe". The syntax for this query is OK and the script runs just fine as long as I don't have a caret in the query string.
In addition, if I connect via tcp socket to a remote sarad runnning on a linux machine, the code executes fine as well, including the queries with a caret.
So the question is: Is this likely to be a problem of the sarad server as compiled under OS X (I would then try to get in touch with the programmer) or do you see any other possible ways how the caret could get mixed up?
Many thanks in advance for any suggestions.
Sebastian