Multiple choice technology programming languages

What will be printed?my @a = (1, undef, 2);my \$sum = 0;foreach my \$val (@a) { eval { \$sum += foo(\$val); }; if (\$@) { \$sum += 100; }}print "\$sum\n";sub foo { my \$val = shift; die "I don't like undefs" unless defined \$val; return \$val + \$val;}

  1. 2

  2. 6

  3. 106

  4. I don't like undefs

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

The array @a contains (1, undef, 2). The loop iterates three times: first val=1, foo(1) returns 2, sum becomes 2; second val=undef, foo(undef) dies with error message, eval catches it ($@ is true), so sum += 100 making sum = 102; third val=2, foo(2) returns 4, sum becomes 106. The print outputs 106. The eval block traps the die() on undefined input, adding 100 instead of failing.