NAME

Gnuplot::Builder::Process - gnuplot process manager

SYNOPSIS

use Gnuplot::Builder::Process;

@Gnuplot::Builder::Process::COMMAND = ("/path/to/gnuplot", "-p");
$Gnuplot::Builder::Process::ENCODING = "utf8";

DESCRIPTION

Gnuplot::Builder::Process class manages gnuplot processes spawned by all Gnuplot::Builder::Script objects.

You can configure its package variables to change its behavior.

CLASS METHODS

Gnuplot::Builder::Process->wait_all()

Wait for all gnuplot processes to finish.

If there is no gnuplot process running, this method returns immediately.

PACKAGE VARIABLES

The default values for these variables may be changed in future releases.

$ASYNC

If set to true, plotting methods of Gnuplot::Builder::Script run in the asynchronous mode by default. See Gnuplot::Builder::Script for detail.

By default, it's 0 (false).

You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_ASYNC.

@COMMAND

The command and arguments to run a gnuplot process.

By default, it's ("gnuplot", "--persist").

You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_COMMAND.

$ENCODING

If set, Gnuplot::Builder encodes the script string in the specified encoding just before streaming into the gnuplot process. You can specify any encoding names recognizable by Encode module.

By default it's undef, meaning it doesn't encode the script.

You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_ENCODING.

$MAX_PROCESSES

Maximum number of gnuplot processes that can run in parallel. If $MAX_PROCESSES <= 0, the number of processes is unlimited.

By default, it's 2.

You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_MAX_PROCESSES.

$NO_STDERR

If set to true, gnuplot's STDERR will not appear in the return value of Gnuplot::Builder::Script's plotting methods (plot(), plot_with(), splot() ... etc). It returns STDOUT only. You can use this to prevent warnings in the output.

By default it is 0 (false). You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_NO_STDERR.

$PAUSE_FINISH

If set to true, Gnuplot::Builder sends "pause mouse close" command to the gnuplot process just before finishing the script.

By default, it's 0 (false).

You can also set this variable by the environment variable PERL_GNUPLOT_BUILDER_PROCESS_PAUSE_FINISH.

$TAP

A subroutine reference to tap the IPC with the gnuplot process. This is useful for debugging.

If set, the subroutine reference is called for each event.

$TAP->($pid, $event, $body)

where $pid is the PID of the gnuplot process, $event is a string describing the event type, and $body is an object describing the event.

Currently $event is always "write", which is called every time some data is written to the gnuplot process. $body is the written string.

To set $TAP from outside the program, use Gnuplot::Builder::Tap.

Example:

local $Gnuplot::Builder::Process::TAP = sub {
    my ($pid, $event, $body) = @_;
    warn "PID:$pid, EVENT:$event, BODY:$body";
};

AUTHOR

Toshio Ito, <toshioito at cpan.org>