use IPC::Run qw( run ); my ($stdout, $stderr); run ["gnuplot", $cmd], undef, \$stdout, \$stderr;