awk 一特殊用法 - Linux
By Linda
at 2013-02-22T04:30
at 2013-02-22T04:30
Table of Contents
#!/usr/bin/env perl
# It reads from STDIN
while ($string=<STDIN>) {
# push $string to @lines until reach numbers
push @lines, $string and next unless $string =~ /^\d+/;
# print @lines if last element is 'ccc'
print @lines if $lines[$#lines] =~ /ccc/;
# reset @lines with first element as numbers
@lines = ($string);
}
# handle end of file
print @lines if $lines[$#lines] =~ /ccc/;
Perl 處理文字真的超強,不考慮學一下嗎?XD
--
# It reads from STDIN
while ($string=<STDIN>) {
# push $string to @lines until reach numbers
push @lines, $string and next unless $string =~ /^\d+/;
# print @lines if last element is 'ccc'
print @lines if $lines[$#lines] =~ /ccc/;
# reset @lines with first element as numbers
@lines = ($string);
}
# handle end of file
print @lines if $lines[$#lines] =~ /ccc/;
Perl 處理文字真的超強,不考慮學一下嗎?XD
--
Tags:
Linux
All Comments
By Steve
at 2013-02-26T01:08
at 2013-02-26T01:08
By James
at 2013-03-02T08:47
at 2013-03-02T08:47
By Puput
at 2013-03-06T05:18
at 2013-03-06T05:18
By Andy
at 2013-03-06T13:52
at 2013-03-06T13:52
Related Posts
awk 一特殊用法
By Genevieve
at 2013-02-21T23:14
at 2013-02-21T23:14
pcmanx-gtk2 1.2 released
By Poppy
at 2013-02-21T21:50
at 2013-02-21T21:50
Ubuntu12.04下灌xfce、kde更新問題
By Lydia
at 2013-02-21T20:34
at 2013-02-21T20:34
Ubuntu12.04下灌xfce、kde更新問題
By Xanthe
at 2013-02-21T17:25
at 2013-02-21T17:25
ubuntu 安裝套件
By Oliver
at 2013-02-21T13:11
at 2013-02-21T13:11