Re: Pipe inside perl one liner

2007-02-11 Thread Peter Scott
On Sun, 11 Feb 2007 00:38:02 +, vjp2 wrote:
 I wonder if it is possibl to merge these two perl one liners inside one perl
 one liners, by putting the pipe statement inside?
 
 speach () { cat $1 | perl -n00e'tr/\t\r\n/ /s; print qq($1\n) while 
 s/^(.{0,36}\S)\s+//;print qq(\n)' | perl -pe 'if ($.%4==2) {$_ .= 
 qq(\n).(q(-) x 37).qq(\n)} elsif ($.%4==0) {$_ .= qq(\n).(q(=) x 37).qq(\n)} 
 else {$_ .= qq(\n)}' ;}

Why, are you trying to win a contest to see who can produce the most
unmaintainable code?

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: pipe in perl ???

2003-01-15 Thread John W. Krahn
Martin A. Hansen wrote:
 
 hi

Hello,

 how to use an array as input for a external command called within a perl script?
 
 im looking to pipe the array to the extarnal program ...

open PIPE, '| somecommand' or die Cannot open pipe to somecommand: $!;

print PIPE @array;

close PIPE or die Cannot close pipe to somecommand: $!;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 05:34:59AM -0800, John W. Krahn wrote:
 Martin A. Hansen wrote:
  
  hi
 
 Hello,


hi again


 
  how to use an array as input for a external command called within a perl script?
  
  im looking to pipe the array to the extarnal program ...
 
 open PIPE, '| somecommand' or die Cannot open pipe to somecommand: $!;
 
 print PIPE @array;
 
 close PIPE or die Cannot close pipe to somecommand: $!;
 

i figured that much, but that is not the way to solve my gnuplot problem. i
need to translate the following commandline to perl:

(echo set term post; echo plot '-' w l; cat data) | gnuplot  data.ps

where cat data is replaced by a pipe of some sort ...

gnuplot is tricky because the plot '-' part means that the data is supplied
followingly


gnuplot is wierd, but i hope perl can unwierd it


martin
 
 
 John
 -- 
 use Perl;
 program
 fulfillment
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread wiggins
Sorry if I already missed a post where you said you couldn't (have had the flu), but 
could you use one of the various modules in CPAN to control gnuplot instead of trying 
to manipulate it yourself?

A quick search:
http://search.cpan.org/search?query=Gnuplotmode=all
http://search.cpan.org/author/CAIDAPERL/Chart-Graph-2.0/Graph/Gnuplot.pm
http://search.cpan.org/author/ILYAZ/Term-Gnuplot-0.5704/Gnuplot.pm

Just a thought.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 08:27:13AM -0600, [EMAIL PROTECTED] wrote:
 Sorry if I already missed a post where you said you couldn't (have had the flu), but 
could you use one of the various modules in CPAN to control gnuplot instead of trying 
to manipulate it yourself?
 

hi

i did look at it, but i found it confusing. anyhows, i need to learn perl and
redirecting output is good to know.


martin


 A quick search:
 http://search.cpan.org/search?query=Gnuplotmode=all
 http://search.cpan.org/author/CAIDAPERL/Chart-Graph-2.0/Graph/Gnuplot.pm
 http://search.cpan.org/author/ILYAZ/Term-Gnuplot-0.5704/Gnuplot.pm
 
 Just a thought.
 
 http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: pipe in perl ???

2003-01-15 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
 i need to translate the following commandline to perl:
 
 (echo set term post; echo plot '-' w l; cat data) | gnuplot 
 data.ps 

   open(F, | gnuplot data.ps) or die $!;
   print F set term post\n, plot '-' w l\n;
   print $_\n for @commands;
   close F or die $!;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: pipe in perl ???

2003-01-15 Thread Bob Showalter
Bob Showalter wrote:
 [EMAIL PROTECTED] wrote:
  i need to translate the following commandline to perl:
  
  (echo set term post; echo plot '-' w l; cat data) | gnuplot 
  data.ps
 
open(F, | gnuplot data.ps) or die $!;
print F set term post\n, plot '-' w l\n;
print $_\n for @commands;

Oops, forgot the filehandle. That should be

 print F $_\n for @commands;

close F or die $!;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 10:33:45AM -0500, Bob Showalter wrote:
 Bob Showalter wrote:
  [EMAIL PROTECTED] wrote:
   i need to translate the following commandline to perl:
   
   (echo set term post; echo plot '-' w l; cat data) | gnuplot 
   data.ps
  
 open(F, | gnuplot data.ps) or die $!;
 print F set term post\n, plot '-' w l\n;
 print $_\n for @commands;
 
 Oops, forgot the filehandle. That should be
 
  print F $_\n for @commands;
 

perfect! i got the same syntax working just before reading this :)))

thanx

martin


 close F or die $!;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]