in reply to Please Help With Perl

Line 2 for the first question should be:

foreach(@this_array) {

... because @this_array and $this_array are different and unrelated variables.

And for the other question, line 2 should be:

%car_hash = reverse(%car_hash);

... again because $car_hash and %car_hash are different variables, but also because reverse() returns the reversed hash, so you need to assign it somewhere.

I'm surprised the exam questions contain such basic errors.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Please Help With Perl
by marto (Cardinal) on May 21, 2013 at 10:36 UTC

    "I'm surprised the exam questions contain such basic errors."

    Perhaps this is the purpose of the question, to introduce a problem and ask what they output will be, and why.