in reply to Selecting successive lines

I have a simple way
keep a flag,when you get the name set the flag as one and if flag is one then get score.

foreach(traverse data) { if($data =~ /jack/) { //put some variable here for name $flag=1; } if($flag ==1 && $data=~ /Math Score2 - /) { $score=$'; $flag=0; } }

Since you need to check for multiple names , you may also use
if ( grep( /^$data$/, @array ) )