Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: Memory Leaks and %+

by ruzam (Curate)
on Mar 01, 2012 at 14:07 UTC ( #957226=note: print w/ replies, xml ) Need Help??

in reply to Re: Memory Leaks and %+
in thread Memory Leaks and %+

Isn't it easier to just switch over to $1 and $2 at this point? Your new substr workaround isn't very readable (to me anyway), so it appears that you've lost the one thing you were hoping to gain by using %+.

my $regexp = qr/(\d+)\s+(\d+)/; while(<$fh>) { next unless /$regexp/; my $value1 = $1; my $value2 = $2; print "GOT $value1 $value2\n"; }

Comment on Re^2: Memory Leaks and %+
Download Code
Replies are listed 'Best First'.
Re^3: Memory Leaks and %+
by BrowserUk (Pope) on Mar 01, 2012 at 15:16 UTC

    I completely agree yours is more readable that the OPs alternate version. But even more readable is:

    my $regexp = qr/(\d+)\s+(\d+)/; while(<$fh>) { my( $value1, $value2 ) = /$regexp/ or next; print "GOT $value1 $value2\n"; }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://957226]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-10-06 15:34 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (154 votes), past polls