https://blog.csdn.net/ahilll/article/details/82712694
foreach (<STDIN>){
chomp;
if (/gao/){
print "$_ was matched ‘gao‘\n";
}
}
上面使用了默认的参数变量$,它表示foreach迭代的每一行数据;上面还简写的正则匹配方式/gao/,它等价于$ =~ m/gao/。
如果要自己定义参数, 必须是$_ = "somevalue";
my $value = "value";
my $_= $value;
if (/gao/){
print "yes"
}