Perl中的文件读写学习笔记

2019-10-01 10:23:20丽君

六、打开管道

用程序的形式也可以象命令行一样打开和使用管道(ex:ls>tempfile)。如语句open (MYPIPE, "| cat >hello"); 打开一个管道,发送到MYPIPE的输出成为命令"cat >hello"的输入。由于cat命令将显示输入文件的内容,故该语句等价于open(MYPIPE, ">hello"); 用管道发送邮件如下:

 open (MESSAGE, "| mail dave");
 print MESSAGE ("Hi, Dave! Your Perl program sent this!n");
close (MESSAGE);