Multiple choice technology programming languages

What will be printed? use strict; my @a = (1, 2, 3); my %b = (2 => undef); for my $val (@a) { last if $b{$val}; } print $val;

  1. undef

  2. 0

  3. 1

  4. 2

  5. the code is ill-formed

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

This code has a scoping bug - $val is declared inside the for loop, so it's not accessible after the loop ends. Perl 'use strict' requires variables to be declared before use. The print statement cannot access $val.