in reply to pattern matching

Always use strictures (use strict; use warnings;). That code should have generated the warning:

Use of uninitialized value in concatenation (.) or string at ...

True laziness is hard work