if ($file_content =~ m{ \@user_info_start \s* \n (.*?) \n [^\n]*? \@user_info_end (?! \S) }xms) { my $user_info = $1; ... }