my $html =<<'HTML';
  1. Question1? Answer1.
  2. Question2? Answer2.
  3. Statement. Response to statement.
  4. Question3?
    Answer3.
HTML my (@questions, @answers); while ($html =~ m{
  • \n ( [^<]+ ) }xmsg ) { my $text = $1; if ($text =~ / [?] /xms ) { my @pieces = split / (?<=[?]) \s* /xms, $text; push @questions, $pieces[0]; if (@pieces == 2) { chomp $pieces[1]; push @answers, $pieces[1]; } else { $html =~ m{ \G
                              (.+?)
                              
    }xms; push @answers, $1; } } } print "@questions \n"; print "@answers \n"; --output:-- Question1? Question2? Question3? Answer1. Answer2. Answer3.