加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何跳转到Perl中的特定输入行?

发布时间:2020-12-15 21:49:06 所属栏目:大数据 来源:网络整理
导读:我想跳到包含“include”的第一行. until /include/; 为什么这不起作用? 解决方法 匹配运算符默认使用$_但是默认情况下,运算符不存储到$_,除非它在while循环中使用,因此$_中没有存储任何内容. 来自perldoc perlop: I/O Operators ... Ordinarily you must
我想跳到包含“include”的第一行.
<> until /include/;

为什么这不起作用?

解决方法

匹配运算符默认使用$_但是<>默认情况下,运算符不存储到$_,除非它在while循环中使用,因此$_中没有存储任何内容.

来自perldoc perlop:

   I/O Operators
   ...

   Ordinarily you must assign the returned value to a variable,but there
   is one situation where an automatic assignment happens.  If and only if
   the input symbol is the only thing inside the conditional of a "while"
   statement (even if disguised as a "for(;;)" loop),the value is auto                        

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读