Help for this page

Select Code to Download


  1. or download this
    while( <DATA> ) {
        print if /^Header2:/ .. eof;
    ...
    Header2: <headertwo@example.com
    Received: from server.cluster1.example.com ([10.20.201.160])
            line 12
    
  2. or download this
    my $input = do { local $/ = undef; <DATA> };
    
    if ( $input =~ /^(Header2:.+)/ms ) {
        print $1;
    }
    
  3. or download this
    my $input;
    {
    ...
        $input = <DATA>;
    }
    print join '', ( split /^(Header2:)/m, $input, 3 )[ 1, 2 ];
    
  4. or download this
    print join '', ( split /^(?=Header2:)/m, $input, 2)[1];
    
  5. or download this
    perl -ne 'print if /^Header2:/ .. eof' testdata.txt
    
    ...
    perl -0777 -pe '$_=join q//,(split /^(Header2:)/m,$_,3)[1,2]' testdata
    +.txt
    
    perl -0777 -pe '$_=join q//,(split /^(?=Header2:)/m,$_,2)[1]' testdata
    +.txt