On 10/28/09 Wed  Oct 28, 2009  3:00 PM, "ANJAN PURKAYASTHA"
<anjan.purkayas...@gmail.com> scribbled:

> Trying to learn how to run Gnuplot via a Perl script I came across the
> following helpful example:
> 
> #!/usr/bin/perl
> # Generate postscript and png plot with GNUplot from Perl
> # Author: Ioan Vancea
> # Usage: Give "data file" as an argument for script
> 
> use strict;
> use warnings;
> 
> my $file = ARGV[0];
> 
> # POSTSCRIPT
> open (GNUPLOT, "|gnuplot");
> print GNUPLOT <<EOPLOT;
> set term post color "Courier" 12
> set output "$file.ps"
> set size 1 ,1
> set nokey
> set data style line
> set xlabel "frequency" font "Courier,14"
> set title "Fast Fourier Transform" font "Courier,14"
> set grid xtics ytics
> set xtics 100
> plot "$file" using 1:2 w lines 1
> EOPLOT
> close(GNUPLOT);
> 
> A filehandle to run a program ?!! And what is that pipe symbol doing there?
> Would appreciate any pointers to how this works or where I can read up
> about this.

The pipe symbol tells Perl that the "file name" is the name of program that
you want started. The position of the pipe symbol at the beginning of the
file name means that you want the output file handle GNUPLOT connected
("piped") to the standard input of the specified program, gnuplot in this
instance.

See 'perldoc -f open' and 'perldoc perlipc' for details.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to