MCQs > IT & Programming > Perl > The following program, when executed, should generate the output, 'Sample'; however, the program contains an error. Identify the line with error. 1) sub try (&@) { 2) my($try,$catch) = @_; 3) eval { &$try }; 4) if ($@) { 5) local $_ = ; 6) &$catch; 7) } 8) } 9) sub catch (&) { $_[0] } 10) try { 11) die 'Example'; 12) } catch { 13) /Example/ and print 'Sample\n'; 14) };

Perl MCQs

The following program, when executed, should generate the output, "Sample"; however, the program contains an error. Identify the line with error.

1)   sub try (&@) {

2)            my($try,$catch) = @_;

3)        eval { &$try };

4)        if ($@) {

5)        local $_ = ;

6)            &$catch;

7)   }

8)   }

9)   sub catch (&) { $_[0] }

10)   try {

11)        die "Example";

12)   } catch {

13)            /Example/ and print "Sample\n";

14)   };


Answer

Correct Answer:


Explanation:

Note: This Question is unanswered, help us to find answer for this one

Perl Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Perl Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it