my $input = do { local $/ = undef; }; if ( $input =~ /^(Header2:.+)/ms ) { print $1; }