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.