use File::Temp (); sub showgraph { my($cmdfile, $cmdfilename); my $cmds = qq[set key off\nplot "] . quote($outname) . qq[" with lines\n! echo "Press return to continue" ; read\n]; ($cmdfile, $cmdfilename) = File::Temp::tempfile undef, "UNLINK", 1; $out or die "error creating temporary commands file"; print "Writing gnuplot command to temporary file $cmdfilename\n"; print $cmdfile $cmds or die "error writing command file: $!"; flush $cmdfile or die "error flushing comand file"; print "Launching gnuplot\n"; system "gnuplot", $cmdfilename; close $cmdfile; }