Multiple choice technology programming languages

What is the output of the follwing code snippet: $mystring = "The start text always precedes the end of the end text."; if($mystring =~ m/start(.*)end/) { print $1; }

  1. text always precedes the

  2. text always precedes the end of the end

  3. text always precedes the end of the

  4. None of the above

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

In Perl, the * quantifier is greedy by default. The pattern start(.*)end matches from the first "start" to the last "end" in the string. Thus, $1 captures everything between "start" and the final "end", which is "text always precedes the end of the".