http://qs321.pair.com?node_id=957214


in reply to Memory Leaks and %+

Dang. I was hoping it was something wrong with my code, and therefore fixable. Unfortunately, for the intent & purpose of my particular script I'm stuck with 5.10. Network distribution and company policy and all that.

I will try it out on a newer version when I get the chance and report back, though.

In the meantime, I've found a quick n'dirty fix in case anyone else encounters this archaic headache. Just switch to @+ and @- instead of the more convenient %+:

#!/usr/bin/perl use strict; use warnings; open(my $fh, '<', 'EXAMPLE.TXT'); my $regexp = qr/(?<value1>\d+)\s+(?<value2>\d+)/; while(<$fh>) { next unless /$regexp/; my $value1 = substr($_, $-[1], $+[1] - $-[1]); my $value2 = substr($_, $-[2], $+[2] - $-[2]); print "GOT $value1 $value2\n"; }

And thanks for the responses!

-Maph