The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

IRC::Indexer::Output - Turn trawler output into something useful

SYNOPSIS

  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);

DESCRIPTION

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.

API

When writing an output subclass, you will need to override the methods dump() and write() to set a proper Output scalar:

  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);
  }

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>