On Thu, Sep 18, 2003 at 11:20:07PM -0400, Guest via RT wrote:
Show quoted text> i'd very much like to see filter::block support a length encoding that
> does not produce null-terminated ascii strings. pack("N",length())
> would be what i'd suggest.
>
> the actual change to the filter is marginal (about 4 lines), but the
> question is when and how to deal with perl becoming 64bit-clean.
>
> if this fixed-length length encoding is not something you want to
> implement, may i suggest to have the manpage at least mention the
> actual encoding used?
>
> regards
> az
I appreciate your request, but it doesn't include a compelling reason to
make the change. Furthermore, the current method is already 64bit-clean
and endian-agnostic, so I feel it's superior.
I agree that its protocol should be documented. Also, it might be
useful to support pack("N",length()) in addition to the current method.
Perhaps something more flexible, such as:
LengthEncoder => \&encode_length,
LengthDecode => \&decode_length,
sub encode_length {
my $length = shift;
return "$length\0";
}
sub decode_length {
my $buffer_ref = shift;
return $1 if $$buffer_ref =~ s/^(\d+)\0//;
return; # undef
}
LengthEncoder => \&encode_pack,
LengthDecoder => \&decode_pack,
sub encode_pack {
my $length = shift;
return pack("N", $length);
}
sub decode_pack {
my $buffer_ref = shift;
return if length($$buffer_ref) < 4;
return unpack "N", substr $$buffer_ref, 0, 4, "";
}
That would make the filter much more flexible when dealing with external
protocols.
--
Rocco Caputo - rcaputo@pobox.com -
http://poe.perl.org/