perl单线将一组序列放在一个块中处理
如何将一组序列放在其超集组中的一组序列,在一个代码中处理
任务失败:
$ for i in {1..9} ;{ echo $i ;} |perl -pe 'my $s; if (/3/) { while(1) { $s .= $_; print $s; last if (/7/) } } '
使用perl -pe -pe
option do option do do ofting oft ofting oft OF String行的输出:
1
2
3
4567
8
9
How Perl one-liner for herding a group of sequences, out of its superset group, to be processed in a block of codes
The task fail done:
$ for i in {1..9} ;{ echo $i ;} |perl -pe 'my $s; if (/3/) { while(1) { $s .= $_; print $s; last if (/7/) } } '
to use Perl -pe
option do output of string lines of:
1
2
3
4567
8
9
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用此perl单线:
perl单线使用以下命令行标志:
-e
:告诉Perl在线寻找代码,而不是在文件中。-n
:一次循环一行,将其分配给$ _
默认情况下。-l </code>:在 *nix上(
nix)上剥离输入行分隔符(“ \ n”
),然后再执行代码在线执行代码,并在打印时将其附加。另请参见:
perldoc perlrun
:Use this Perl one-liner:
The Perl one-liner uses these command line flags:
-e
: Tells Perl to look for code in-line, instead of in a file.-n
: Loop over the input one line at a time, assigning it to$_
by default.-l
: Strip the input line separator ("\n"
on *NIX by default) before executing the code in-line, and append it when printing.SEE ALSO:
perldoc perlrun
: how to execute the Perl interpreter: command line switches