[Bioperl-l] how to use pipe in perl script?

Zhou Yu zhouyuwhu at hotmail.com
Tue Apr 20 08:04:44 EDT 2004

Thankls to all! I know what to do with your help!

<html><div><STRONG><FONT color=#ff0033 size=4>Best wishes! 
<BR><BR></FONT>Yu Zhou</STRONG></div></html>

&gt;From: Heikki Lehvaslaiho &lt;heikki at ebi.ac.uk&gt;
&gt;To: Paulo Almeida &lt;paulo.david at netvisao.pt&gt;, Zhou Yu 
&lt;zhouyuwhu at hotmail.com&gt;,   bioperl-l at bioperl.org
&gt;Subject: Re: [Bioperl-l] how to use pipe in perl script?
&gt;Date: Tue, 20 Apr 2004 10:42:08 +0000
&gt;My guess is that Andreas answered the right question but did not give 
&gt;I remember being confused on how to read from STDIN in perl. Here is an
&gt;example oneliner that demonstates it. It helps if you remember that 
&gt;while(&lt;&gt;){...} can be invoked by using -n to perl:
&gt;perl -le 'for (1..10) {print $_}' | perl -nle 'print &quot;item 
&gt;	-Heikki
&gt;On Monday 19 Apr 2004 11:54, Andreas Kahari wrote:
&gt; &gt; Another solution for another interpetation of the problem:
&gt; &gt;
&gt; &gt; If you want to do something like
&gt; &gt;
&gt; &gt;     script1.pl | script2.pl
&gt; &gt;
&gt; &gt; Then script1.pl should write it's results to standard output
&gt; &gt; (&lt;STDOUT&gt;, the default for e.g. print()), and script2.pl 
&gt; &gt; read its input from standard input (&lt;STDIN&gt;).  And that's 
&gt; &gt; there is to it.
&gt; &gt;
&gt; &gt;
&gt; &gt; Andreas
&gt; &gt;
&gt; &gt; On Mon, Apr 19, 2004 at 12:30:48PM +0100, Paulo Almeida wrote:
&gt; &gt; &gt; You can use the 'system' command to do something like this:
&gt; &gt; &gt;
&gt; &gt; &gt; system(&quot;program1 -infile filename | program2&quot;);
&gt; &gt; &gt;
&gt; &gt; &gt; If that doesn't work for some reason, you could write the 
output of the
&gt; &gt; &gt; first program to a file, and then open it with the second 
&gt; &gt; &gt;
&gt; &gt; &gt; system(&quot;program1 -infile filename &gt; output&quot;);
&gt; &gt; &gt; system (&quot;program2 &lt; output&quot;);
&gt; &gt; &gt;
&gt; &gt; &gt; I hope that's what you wanted, I'm not sure I understood...
&gt; &gt; &gt; -Paulo Almeida
&gt; &gt; &gt;
&gt; &gt; &gt; Zhou Yu wrote:
&gt; &gt; &gt; &gt;Hi,
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt;How to use pipe in a script, like redirecting the output 
of a program
&gt; &gt; &gt; &gt;to another program in a script?
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt;For example, I use this command &quot;program1 -infile 
filename | program2&quot;
&gt; &gt; &gt; &gt;in the command line, and how can I to do this in a 
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt;Thanks!
&gt; &gt; &gt; &gt;*
&gt; &gt; &gt; &gt;Yu Zhou*
&gt; &gt; &gt;
&gt; &gt; &gt; _______________________________________________
&gt; &gt; &gt; Bioperl-l mailing list
&gt; &gt; &gt; Bioperl-l at portal.open-bio.org
&gt; &gt; &gt; http://portal.open-bio.org/mailman/listinfo/bioperl-l
&gt;______ _/      _/_____________________________________________________
&gt;       _/      _/                      http://www.ebi.ac.uk/mutations/
&gt;      _/  _/  _/  Heikki Lehvaslaiho    heikki_at_ebi ac uk
&gt;     _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
&gt;    _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
&gt;   _/  _/  _/  Cambs. CB10 1SD, United Kingdom
&gt;      _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
&gt;___ _/_/_/_/_/________________________________________________________
&gt;Bioperl-l mailing list
&gt;Bioperl-l at portal.open-bio.org

ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£  http://www.hotmail.com  

More information about the Bioperl-l mailing list