replace $1 with $& and it works. Thanks!
| [reply] |
PLEASE DON'T USE $&! Take a look at perldoc perlvar for $&. For why $& is generally consider to be a Bad Thing™, check out the documentation for Devel::SawAmpersand. The important parts:
There's a global variable in the perl source, called sawampersand. It gets set to true [..whenever..] the parser sees one of $`, $', and $&. It never can be set to false again.
If the global variable sawampersand is set to true, all subsequent RE operations will be accompanied by massive in-memory copying, because there is nobody in the perl source who could predict, when the (necessary) copy for the ampersand family will be needed. So all subsequent REs (even in places outside of scope) considerably slower than necessary.
That page even offers helpful ways that you can avoid the $&, $`, and $' variables.
Update: Proof of concept since my buddy didn't believe me:
antirice The first rule of Perl club is - use Perl The ith rule of Perl club is - follow rule i - 1 for i > 1
| [reply] [d/l] [select] |