Extracting specific lines with Perl

前端 未结 4 772
孤城傲影
孤城傲影 2021-01-20 20:14

I am writing a perl program to extract lines that are in between the two patterns i am matching. for example the below text file has 6 lines. I am matching load balancer and

4条回答
  •  终归单人心
    2021-01-20 20:49

    For files like this, I often use a change in the Record Separator ( $/ or $RS from English )

    use English qw<$RS>;
    local $RS = "\nend\n";
    
    my $record = <$open_handle>;
    

    When you chomp it, you get rid of that line.

    chomp( $record );
    

提交回复
热议问题