Code 1: Code: my @lines = grep /^hi/, @allLines; Code 2: Code: my @lines = (); foreach (@allLines) { push (@lines,$_) if (/^hi/); } What is the difference between the two snippets (Code 1 and Code 2) above?

  1. In code 1, the operation occurs in one command; code 2 iterates each element in the array for matches.

  2. In code 1, the elements of @lines are the indexes in @allLines, in which matches were found.

  3. In code 1, the elements of "@lines" begin with the index in "@allLines", in which the match was found.

  4. In code 1, "@lines" may not necessarily be in the same order; the original lines appear in "@allLines".


Correct Option: C

Find more quizzes: