Multiple choice technology programming languages

my $txt = 'I am learning Perl'; $txt =~ /(\w+)$/; What is value of \$txt?

  1. Perl

  2. I

  3. I am learning Perl

  4. undef

  5. empty string

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

The regex match operator (=~) modifies special variables like $1, $2 etc., but does NOT modify the original variable. $txt still contains the original string 'I am learning Perl'. The pattern /(\w+)$/ matches 'Perl' and stores it in \$1, not in $txt. This is a common misconception about regex behavior.