YUANya

导航

 

读取标准输入

#!/usr/bin/perl

use strict;
use warnings;

my $line=<STDIN>;
my $err = defined($line);print "$err\n";

##j
##1

加入文件1.txt,2.txt
1.txt

yyyyyyyyyyyy

2.txt

yy
cat 1.txt 2.txt | perl test.pl
while(defined($_ = <STDIN>))
{
    print "I saw $_";
}

##I saw yyyyyyyyyyyy
##I saw yy

while(defined($_ = ""))
{
    print "I saw $_\n";
}

##I saw
##I saw
##....

while(defined($_ = undef))
{
    print "I saw $_\n";
}

##
```shell

等待数组结束
```perl
foreach(<STDIN>)
{
    print "I saw $_\n";
}

##kk
##kk
cat 1.txt 2.txt
foreach(<STDIN>)
{
    print "I saw $_\n";
}

##yyyyyyyyyyyyy
##yy
posted on 2019-06-15 19:21  YUANya  阅读(112)  评论(0编辑  收藏  举报