NAME

Podius::IPC - useful interprocess communication related functions


SYNOPSIS

  use Podius::IPC qw(run_command run_filter);
  my $output1 = run_command("grep /root /etc/passwd");
  my $output2 = run_command([ 'grep', '/root', '/etc/passwd' ]);
  # should print lines for users "root", "operator"
  print $output1, $output2;
  my $output3 = run_filter("tr st ST", "something short");
  my $output4 = run_filter([qw(tr st ST)], "something short");
  # should print "SomeThing ShorT"
  print $output3, "\n", $output4, "\n";


DESCRIPTION

This module provides portable useful functions. For example, run_filter function tries to use the IPC::Open2 manpage that is shipped with perl, however the IPC::Open2 manpage does not work correctly under mod_perl, so this case is detected and the IPC::Run manpage is used instead.


FUNCTIONS

$output = run_command($cmd)
$output = run_command(\@cmd)
Runs system command (that is either scalar or array of scalars) and returns the output. Note that only the array-cmd usage is secure.

On any problem the warning is written and undef is returned.

$output = run_filter($cmd, $input)
$output_ref = run_filter(\@cmd, $input_ref)
Runs double piped system command (that is either scalar or array of scalars), then passes input to it (that is either scalar or scalarref) and returns the output. If input is scalarref, then the output will be scalarref too.

On any problem the warning is written and undef is returned.


SEE ALSO

the IPC::Open2 manpage, the IPC::Run manpage.