Click here to get back home

Pipe and Par questions

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Pipe and Par questions E.D.G. 04-28-2008
Posted by E.D.G. on April 28, 2008, 6:37 pm
Please log in for more thread options
PIPE AND PAR QUESTIONS

This might be the second posted copy of this note. The first one does not
appear to have registered. Since it was sent I solved one of the problems
mentioned in it on my own. It involved having Perl start other programs
running using Vista.

Windows Vista has a Run command that can be isolated with a little time and
effort and then used with the System command to start other programs
running. If System is used to start another program without the Run command
on my computer then Perl appears to stop running until the other program
ends.

These questions pertain to ActiveState Perl 5.8.8 running on a Windows XP
computer, and 5.10 running on a Windows Vista computer. The 5.10 version
appears to be quite easy to use for locating, downloading, and merging Perl
modules.

PIPE

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";

Perl did not stop running or generate any error messages. But Gnuplot just
waited for commands and did not do anything.

PAR

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.






Posted by Ben Bullock on April 28, 2008, 6:33 pm
Please log in for more thread options
On Mon, 28 Apr 2008 16:37:56 -0600, E.D.G. wrote:

> Commands I tried are different variations of:
>
> Open (Program, "| program name");
> Print Program 'information', "\n";

"Open" and "Print" aren't Perl, but perhaps your news software has added
some bogus capitals. The first thing to check is the return value of
"open" (not "Open") with something like

open my $program, "|-", 'C:/Program Files/Gnuplot/gnuplot.exe'
        or die $!;

> Perl did not stop running or generate any error messages.

It doesn't:

#!/usr/bin/perl
open MONEY, "Fort Knox";

ben ~ 536 $ ./fort_knox
ben ~ 537 $

> 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.

If they can download gnuplot, I assume they can download ActiveState Perl
as well.

Posted by E.D.G. on April 28, 2008, 7:45 pm
Please log in for more thread options
> "Open" and "Print" aren't Perl, but perhaps your news software has added
> some bogus capitals. The first thing to check is the return value of
> "open" (not "Open") with something like
>
Actually, I do use lower case open and print as you suggested. My word
processor program changed them to upper case in the Newsgroup note without
my catching that. Thanks again for the suggestions.


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]

Posted by E.D.G. on April 28, 2008, 7:40 pm
Please log in for more thread options
>

Thanks for the command suggestions. I will give them a try.

As far as other people downloading and running Perl, we are talking about
folks around the world who may be scientists but who might know essentially
nothing about computer programming, not that I myself am an expert. Many of
them might not even be able to speak English. But with a Perl .exe program
they will not have to learn how to load modules etc. They can just enter
numbers and watch as Gnuplot creates technical charts and graphs for them.


Similar ThreadsPosted
Fundamental pipe questions March 30, 2007, 10:00 am
SIG October 3, 2007, 9:41 pm
children not getting eof from pipe June 19, 2005, 9:40 pm
WIN32::PIPE bug ? June 13, 2006, 11:25 pm
Zero equals pipe?? September 23, 2006, 9:17 pm
writing to a pipe on win32 July 26, 2004, 12:42 pm
open of a pipe and waitpid() August 25, 2004, 12:51 pm
FAQ 8.23: How can I open a pipe both to and from a command? October 31, 2004, 6:03 pm
FAQ 8.23: How can I open a pipe both to and from a command? November 5, 2004, 12:03 am
FAQ 8.23 How can I open a pipe both to and from a command? March 14, 2005, 6:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap