In Expat/Expat.xs, line 374 in my version reads:
cnt = perl_call_method("read", G_SCALAR);
Change this to:
cnt = perl_call_method("sysread", G_SCALAR);
Then "make install". That should do ya (on Unix-like systems, at least), although I would like to reiterate that a well-formed XML document has a single top-level element, so it can't really be considered parsed until you get to the end.
Another way to do this is to subclass IO::Socket::INET to override the read method.
Update: Here's how you would do the subclassing thing:
use strict;
use XML::Parser;
use IO::Socket::INET;
{
package DebufSocket;
our @ISA = qw(IO::Socket::INET);
sub read {
my $self = shift;
$self->sysread(@_);
}
}
sub handle_elem_start {
my ($expat,$name,$atts) = @_;
print "in element \"$name\", at byte ".$expat->current_byte()." in s
+tream\n";
}
my $sock=DebufSocket->new(
PeerAddr => '162.134.173.177',
PeerPort => 6537) or die "socket: $!\n";
my $parser=XML::Parser->new(
Style => 'Stream',
Handlers => {
Start => \&handle_elem_start
}
);
$parser->parse($sock);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.