Re: [問題] awk 一特殊用法
#!/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
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 68.181.7.7
推
02/22 08:57, , 1F
02/22 08:57, 1F
→
02/22 19:44, , 2F
02/22 19:44, 2F
→
02/22 19:45, , 3F
02/22 19:45, 3F
→
02/23 00:31, , 4F
02/23 00:31, 4F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
問題
1
2