|
Posted by Ben Morrow on April 28, 2008, 6:34 pm
Please log in for more thread options
>
> What needs to be done to get Perl 5.10 (and Vista) to send information and
> commands directly to a separate program? Perl is being used with
> Gnuplot.exe, a versatile and powerful free, downloadable graphics program.
> In the past I had Perl store information in a file that Gnuplot checked
> several times a second. That worked. But attempts to get Perl to send
> Gnuplot information directly using a Pipe have not been successful.
> Commands I tried are different variations of:
>
> Open (Program, "| program name");
> Print Program 'information', "\n";
This is not valid Perl: Perl is case-sensitive. Please port tha actual
code you have run.
On my machine (5.8.8/i686-freebsd), the following works perfectly:
#!/usr/bin/perl
use warnings;
use strict;
open my $GP, '|-', qw/gnuplot -/
or die "can't run gnuplot: $!";
print $GP <<GP;
plot sin(x)
pause mouse
GP
close $GP or die "writing to gnuplot failed: $!";
__END__
I would expect it to work on yours also: is this not the case?
> Perl did not stop running or generate any error messages. But Gnuplot just
> waited for commands and did not do anything.
Have you read the gnuplot documentation? You must pass a '-' argument to
get it to read commands from stdin.
> The plan is to generate .exe versions of my Perl programs and then circulate
> them for free use to other researchers around the world who can download
> their own copies of Gnuplot.
>
> Has anyone worked with the PAR module to create .exe programs? Is PAR the
> correct module to use? It would be helpful to see the exact commands that
> need to be used to generate .exe programs. When I tried to use PAR in the
> past I did not have much success.
IME it works very well, especially more recent versions.
Ben
--
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one.
'We come in peace'---the order came to cut them down. [ben@morrow.me.uk]
|