Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: global variable initialization inside try{}

by perrin (Chancellor)
on Apr 09, 2009 at 15:34 UTC ( #756638=note: print w/replies, xml ) Need Help??

in reply to global variable initialization inside try{}

I recommend you stop using the try{} syntax from Error, for thse reasons.
  • Comment on Re: global variable initialization inside try{}

Replies are listed 'Best First'.
Re^2: global variable initialization inside try{}
by targetsmart (Curate) on Apr 10, 2009 at 06:13 UTC
    I just read this Re: Re2: Learning how to use the Error module by example
    where it was told that the below code will leak memory
    use Error qw( :try ); sub leaky_function { my $foo = 7; try { # do something here try { $foo++; } catch Error::Simple with { # whatever }; } catch Error::Simple with { # whatever }; }
    please explain me how it leaks memory when I call it every time.

    -- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
      In the bottom of that post it says that this leak was fixed in recent versions of perl. It used to leak by creating copies of $foo. If you're on a version prior to 5.8, you should still be concerned about it. The other problems with the try{} syntax still exist.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://756638]
[marioroy]: We made it all the way to the end. The expience was magical. I not good at sports. Someone or thing was there.
erix considers extracting a catalog ...
[karlgoethebier]: marioroy: Racket ball is considered harmful, like Squash
[marioroy]: Wait till folks see what MCE::Hobo can do in the upcoming release. Multiple instances, nested spawning, 3 levels, doesn't matter. it works on Windiows too.
[Lady_Aleena]: I hate sites that tell me to turn ad-blocker off. They should know better.
[marioroy]: s/Windiows/ Windows/
[Discipulus]: marioroy can you expand that Niagara's fall history?
erix only sees fallen angels
erix if it weren't for bad luck, I'd have no luck at all
Discipulus Windiows the OS of native americans..

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-05-29 08:46 GMT
Find Nodes?
    Voting Booth?