in reply to Parse Puzzle
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:
which will return the first, second, or third non-newline character, or an undef if the regex doesn't match.sub dis { (shift =~ /.?.?(.)/)[0]; }
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|