How do I extract lines between two line delimiters in Perl?

前端 未结 6 1738
醉酒成梦
醉酒成梦 2020-12-09 06:23

I have an ASCII log file with some content I would like to extract. I\'ve never taken time to learn Perl properly, but I figure this is a good tool for this task.

Th

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 06:31

    while (<>) {
        chomp;      # strip record separator
        if(/END/) { $f=0;}
        if (/START/) {
            s/.*START//g;
            $f=1;
        }
        print $_ ."\n" if $f;
    }
    

    try to write some code next time round

提交回复
热议问题