|P is for Practical
Appending a single Scalar after a matchby SavannahLion (Pilgrim)
|on May 25, 2015 at 08:36 UTC
SavannahLion has asked for the wisdom of the Perl Monks concerning the following question:
So I found myself updating an old script (parses oodles of HTML files). and unknowingly introduced a subtle bug.
Without thinking, I made a subtle change.
A '1' kept getting shoved into $k. Goes without saying that I spend hours chasing this new bug down until I realized I was trying to use a list in a scalar context. So after much cursing I went and fixed the bug like thus.
After a fashion, I got to thinking. Is there a way to get it back to a one liner again and still append the value of $1 to $k? I tried several variations on the original but can't seem to work out a solution. My thought was something along the lines of:
I tried several variations but I can't quite seem to get it right. My gut says it should be feasible, but my brain can't quite put it together