The scope of regex capture variables

Question

Various along the lines of "Why does $1 not DWIM?"

Answer

The capture variables are globally global, they are not dynamically or lexically scoped.

Sometimes you can pretend like they are dynamically scoped.

'foo' =~ /(.*)/;
print "$1\n"; # foo
{
  'bar' =~ /(.*)/;
  print "$1\n"; # bar
}
print "$1\n"; # foo

But you will get burned

Next