IRC::Indexer::Output - Turn trawler output into something useful
use IRC::Indexer::Output::JSON; # or: use IRC::Indexer::Output::YAML; # or: use IRC::Indexer::Output::Dumper; ## Convert trawler output into JSON, for example: my $output = IRC::Indexer::Output::JSON->new( Input => $trawler->dump, ); ## Get output as a scalar: print $output->dump; ## Write output to file: $output->write($path);
The IRC::Indexer::Output subclasses can convert IRC::Indexer::Bot::Trawl hashes into portable data formats.
You wouldn't normally use this module directly unless you are writing an output subclass; instead, you would use a subclass for a particular format, such as IRC::Indexer::Output::JSON.
Create an output encoder; the reference to serialize must be specified:
my $out = IRC::Indexer::Output::JSON->new( Input => $ref, );
Return the serialized output as a scalar.
my $json = $out->dump;
Write serialized output to a file path or an opened FH.
$out->write($path);
Will croak() on error.
When writing an output subclass, you will need to override the methods dump() and write() to set a proper Output:
our @ISA = qw/IRC::Indexer::Output/; sub dump { my ($self) = @_; my $input = $self->{Input}; ## Serialize the $input hashref any way you like: $self->{Output} = frobulate_my_input($input); $self->SUPER::dump(); } sub write { my ($self, $path) = @_; my $input = $self->{Input}; $self->{Output} = frobulate_my_input($input); $self->SUPER::write($path); }
Jon Portnoy <avenj@cobaltirc.org>
To install IRC::Indexer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IRC::Indexer
CPAN shell
perl -MCPAN -e shell install IRC::Indexer
For more information on module installation, please visit the detailed CPAN module installation guide.