in reply to Re: How to remove the $1 hard coding
in thread How to remove the $1 hard coding
Actually, after thinking about it, I don't think a symbolic ref solution would be so bad in this case, provided you take a few percautions. At the top of your subroutine, make sure $matchnum matches against /\A\d+\z/ and that $$matchnum is a defined value after the match (change your last line to $result = $$matchnum if $$matchnum;).
Though overall, you're still probably better off with the array solution.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How to remove the $1 hard coding
by shenme (Priest) on Aug 22, 2003 at 21:26 UTC |