Code · 2010-01-06

perl的标准输入STDIN

perl的标准输入stdin

#!/usr/bin/perl
print "wait stdin:";
$sr = ;
if ( $sr eq "\n" ){
   print "just a blank line \n"
}else{
   print "the data of input is $sr"
}

相比shell比较奇怪的是输入为空,perl的判断却是”\n” 换行符!

#!/bin/bash
read a
if [ -z $a ];then
echo “blank line!”
else
echo a
fi