in reply to Parse Puzzle

The times it won't work is when you are using the value in a scalar context, which will return the success status of the match instead of the first memory.

And you still have a problem with your "fix". If the regex doesn't match (like you have only a single newline in the string, or maybe the string is empty), you'll get the previous $1, which will likely be some other random garbage.

Perhaps what you really wanted was this:

sub dis { (shift =~ /.?.?(.)/)[0]; }
which will return the first, second, or third non-newline character, or an undef if the regex doesn't match.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.