in reply to Help with the push function

my $html =<<'HTML'; <ol> <li> Question1? Answer1. <li> Question2? Answer2. <li> Statement. Response to statement. <li> Question3? <pre>Answer3.</pre> </ol> HTML my (@questions, @answers); while ($html =~ m{ <li> \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 <pre> (.+?) </pre> }xms; push @answers, $1; } } } print "@questions \n"; print "@answers \n"; --output:-- Question1? Question2? Question3? Answer1. Answer2. Answer3.