The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POE::Filter::Reference - POE Freeze/Thaw Protocol Abstraction

SYNOPSIS

  $filter = new POE::Filter::Reference();
  $arrayref_of_perl_references =
    $filter->get($arrayref_of_raw_chunks_from_driver);
  $arrayref_of_serialized_perl_references =
     $filter->put($arrayref_of_perl_references);

DESCRIPTION

The "put" half of this filter freezes referenced Perl structures into serialized versions for sending. The "get" half of this filter thaws serialized Perl structures back into references. This provides a handy way to ship data between processes and systems.

Serializers should recognize that POE::Filter::Reference is used to ship data between systems with different byte orders.

PUBLIC FILTER METHODS

  • POE::Filter::Reference::new( ... )

    The new() method creates and initializes the reference filter. It accepts optional parameters to specify a serializer and the use of compression. The serializer may be a package or an object; the compression flag is a Perl "boolean" value.

    A package serializer must have a thaw() function, and it must have either a freeze() or nfreeze() function. If it has both freeze() and nfreeze(), then Filter::Reference will use nfreeze() for portability. These functions match Storable and FreezeThaw's call signatures.

    An object serializer must have a thaw() method. It also must have either a freeze() or nfreeze() method. If it has both freeze() and nfreeze(), then Filter::Reference will use nfreeze() for portability. The thaw() method accepts $self and a scalar; it should return a reference to the reconstituted data. The freeze() and nfreeze() methods receive $self and a reference; they should return a scalar with the reference's serialized representation.

    If the serializer parameter is undef, a default one will be used. This lets programs specify compression without having to worry about naming a serializer.

    For example:

      # Use the default filter (either Storable or FreezeThaw).
      my $filter = new POE::Filter::Reference();
    
      # Use Storable explicitly, specified by package name.
      my $filter = new POE::Filter::Reference('Storable');
    
      # Use an object.
      my $filter = new POE::Filter::Reference($object);
    
      # Use an object, with compression.
      my $filter = new POE::Filter::Reference($object, 1);
    
      # Use the default serializer, with compression.
      my $filter = new POE::Filter::Reference(undef, 1);

    The new() method will try to require any packages it needs.

    The default behavior is to try Storable first, FreezeThaw second, and fail if neither is present. This is rapidly becoming moot because of the PM_PREREQ entry in Makefile.PL, which makes CPAN and ``make'' carp about requirements even when they aren't required.

  • POE::Filter::Reference::get($frozen_data)

    The get() method thaws streamed, frozen data into references. References will be blessed, if necessary. If the reference points to an object, be sure the receiving end has use'd it before calling its methods.

  • POE::Filter::Reference::put($reference)

    The put() method freezes references and returns their serialized, streamable representations.

SEE ALSO

POE::Filter; POE::Filter::HTTPD; POE::Filter::Line; POE::Filter::Stream

BUGS

Oh, probably some.

AUTHORS & COPYRIGHTS

The Reference filter was contributed by Arturn Bergman, with changes by Philip Gwyn.

Please see the POE manpage for more information about authors and contributors.