my $new_act; my $new_scene; while (<$playIn>) { my $line = $_; ... # Print the act heading if we haven't yet. if ($new_act) { print "$new_act\n"; $new_act = undef; } # Print the scene headin if we haven't yet. if ($new_scene) { print "$new_scene\n"; $new_scene = undef; } ... # Step 1.6: We should also print act headings. elsif ($line =~ m/.*

ACT \w+.*/) { $new_act = $line; } # Step 1.7: We should also print scene headings. elsif ($line =~ m/.*

SCENE \w+.*/) { $new_scene = $line; } }