in reply to problems with global $1

Perhaps your regular expression is not matching anything, leaving $1 uninitialized?

non-Perl: Andy Ford