Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Re: Scoping issues with code evaluation asserstions?

by diotalevi (Canon)
on Jun 19, 2003 at 19:08 UTC ( #267308=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Scoping issues with code evaluation asserstions?
in thread Scoping issues with code evaluation asserstions?

You'd need to have declared $ret as a global somewhere for local to localize it. Remember that local() declares nothing.

use vars '$ret'; sub regex { local $ret = '';

What you didn't realize was that the (?{ ... }) is a closure so when it first ran it captured the original $ret and continued to write to that same instance which wasn't the same one being returned in later iterations.


Comment on Re: Re: Re: Scoping issues with code evaluation asserstions?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-12-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (78 votes), past polls