From grant at mclean.net.nz Tue Nov 1 02:40:44 2011 From: grant at mclean.net.nz (Grant McLean) Date: Tue, 01 Nov 2011 22:40:44 +1300 Subject: [Wellington-pm] Meeting in 2 weeks - speakers needed Message-ID: <1320140444.2432.4.camel@hoiho> Hi Mongers The next meeting of Wellington Perl Mongers will be in two weeks on Tuesday the 15th of November. We don't yet have anyone signed up to speak so please email me directly if you'd like to book a slot. Our meeting is one week later than usual this month to avoid a clash with the Ignite Wellington event which is on Tuesday the 8th (next week): http://www.ignitewellington.co.nz/ Regards Grant From andrew at morphoss.com Tue Nov 1 03:11:40 2011 From: andrew at morphoss.com (Andrew McMillan) Date: Tue, 01 Nov 2011 23:11:40 +1300 Subject: [Wellington-pm] Meeting in 2 weeks - speakers needed In-Reply-To: <1320140444.2432.4.camel@hoiho> References: <1320140444.2432.4.camel@hoiho> Message-ID: <1320142300.13890.45.camel@dave.home.mcmillan.net.nz> On Tue, 2011-11-01 at 22:40 +1300, Grant McLean wrote: > Hi Mongers > > The next meeting of Wellington Perl Mongers will be in two weeks on > Tuesday the 15th of November. > > We don't yet have anyone signed up to speak so please email me directly > if you'd like to book a slot. > > Our meeting is one week later than usual this month to avoid a clash > with the Ignite Wellington event which is on Tuesday the 8th (next > week): http://www.ignitewellington.co.nz/ What about avoiding a class with OSDC, hmm? Cheers, Andrew. -- ------------------------------------------------------------------------ andrew (AT) morphoss (DOT) com +64(272)DEBIAN There must be more to life than having everything. -- Maurice Sendak ------------------------------------------------------------------------ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part URL: From lrw at clear.net.nz Thu Nov 3 15:35:37 2011 From: lrw at clear.net.nz (Lesley Longhurst) Date: Fri, 04 Nov 2011 11:35:37 +1300 Subject: [Wellington-pm] How to cure "variable will not stay shared? Message-ID: <4EB31739.2000409@clear.net.nz> Hi mongers, So, I'm looking at some nasty legacy code left behind by Mordac. I added "use warnings; use diagnostics" and got a pile of these warnings. From what I've read so far, it seems that they are caused by a subroutine being defined inside a subroutine. The diagnostics text suggests making the inner subroutine anonymous, but I don't think that's going to work because it's called by name many times. Am I likely to make matters worse if I just take the inner sub and move it outside the outer sub? Most of the variables are defined without "my" and there is no other sub with the same name. -- Lesley Longhurst (previously Walker) Linux Systems Administrator Opus International Consultants Ltd Email lesley.longhurst at opus.co.nz Tel +64 4 471 7002, Fax +64 4 473 3017 http://www.opus.co.nz Level 9 Majestic Centre, 100 Willis Street, PO Box 12 343 Wellington, New Zealand From srdjan at catalyst.net.nz Thu Nov 3 16:08:38 2011 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 04 Nov 2011 09:08:38 +1000 Subject: [Wellington-pm] How to cure "variable will not stay shared? In-Reply-To: <4EB31739.2000409@clear.net.nz> References: <4EB31739.2000409@clear.net.nz> Message-ID: <4EB31EF6.5020202@catalyst.net.nz> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there, On 04/11/11 08:35, Lesley Longhurst wrote: > Hi mongers, > > So, I'm looking at some nasty legacy code left behind by Mordac. I added "use warnings; use diagnostics" and got a pile of these warnings. >From what I've read so far, it seems that they are caused by a subroutine being defined inside a subroutine. The diagnostics text suggests making the inner subroutine anonymous, but I don't think that's going to work because it's called by name many times. > > Am I likely to make matters worse if I just take the inner sub and move it outside the outer sub? Most of the variables are defined without "my" and there is no other sub with the same name. Not likely. It is being called from outside of the outer sub scope anyway, but it should not matter, I think that inner subs vars do not take outer sub scope anyway. Can anyone confirm this? Srdjan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6zHvAACgkQX6p/D9UE7dzPZQCdH3fdy62OSposEtvlJ56WmjMI m+oAn3vxQ3wiDorzs2Kwq/uWIqxsTGkn =tPj8 -----END PGP SIGNATURE----- From grant at mclean.net.nz Thu Nov 3 16:12:57 2011 From: grant at mclean.net.nz (Grant McLean) Date: Fri, 04 Nov 2011 12:12:57 +1300 Subject: [Wellington-pm] How to cure "variable will not stay shared? In-Reply-To: <4EB31739.2000409@clear.net.nz> References: <4EB31739.2000409@clear.net.nz> Message-ID: <1320361977.30274.32.camel@putnam> On Fri, 2011-11-04 at 11:35 +1300, Lesley Longhurst wrote: > Hi mongers, > > So, I'm looking at some nasty legacy code left behind by Mordac. I added > "use warnings; use diagnostics" and got a pile of these warnings. From > what I've read so far, it seems that they are caused by a subroutine > being defined inside a subroutine. It sounds like you're on the right track there. The problem results from the fact that Perl's "my" keyword has compile time and runtime effects. Consider this code snippet: sub outer { my($msg) = @_; my $now = localtime(); sub print_message { my($message) = @_; print "$now $message\n"; } print_message($msg); } outer('First message'); sleep(1); outer('Second message'); sleep(1); outer('Third message'); sleep(1); The inner 'print_message' sub is a closure around the $now variable (this is set up at compile time). But a new $now variable is created each time outer() is called (this happens at run time) and the inner sub is left pointing to the first $now. > The diagnostics text suggests making > the inner subroutine anonymous, but I don't think that's going to work > because it's called by name many times. In my snippet I would do that by changing to: sub outer { my($msg) = @_; my $now = localtime(); my $print_message = sub { my($message) = @_; print "$now $message\n"; }; $print_message->($msg); } This works because the inner print_message sub is redefined each time outer is called(). > Am I likely to make matters worse if I just take the inner sub and move > it outside the outer sub? Most of the variables are defined without "my" > and there is no other sub with the same name. If the variables are defined without "my" then that's roughly equivalent to defining them at the start of the script with "our", e.g.: our($now); sub outer { my($msg) = @_; $now = localtime(); ... Changing it to explicity use "our" might be the lowest risk approach to fixing the problem. Cheers Grant From grant at mclean.net.nz Thu Nov 3 16:23:15 2011 From: grant at mclean.net.nz (Grant McLean) Date: Fri, 04 Nov 2011 12:23:15 +1300 Subject: [Wellington-pm] How to cure "variable will not stay shared? In-Reply-To: <4EB31EF6.5020202@catalyst.net.nz> References: <4EB31739.2000409@clear.net.nz> <4EB31EF6.5020202@catalyst.net.nz> Message-ID: <1320362595.30274.41.camel@putnam> On Fri, 2011-11-04 at 09:08 +1000, Srdjan wrote: > I think that inner subs vars do not > take outer sub scope anyway. Can anyone confirm this? A Perl subroutine does have access to variables from the enclosing scope. This is useful because it allows the inner sub to access the current value of any shared variable at the time the inner sub is called. However this really only makes sense when defining anonymous subroutines and passing them around as callbacks, e.g.: $stop_button->signal_connect(clicked => sub { $app->stop_timer() }); It's almost always a bug in Perl to create a nested named subroutine (as opposed to an anonymous one). Cheers Grant From lrw at clear.net.nz Thu Nov 3 16:54:46 2011 From: lrw at clear.net.nz (Lesley Longhurst) Date: Fri, 04 Nov 2011 12:54:46 +1300 Subject: [Wellington-pm] How to cure "variable will not stay shared? In-Reply-To: <1320362595.30274.41.camel@putnam> References: <4EB31739.2000409@clear.net.nz> <4EB31EF6.5020202@catalyst.net.nz> <1320362595.30274.41.camel@putnam> Message-ID: <4EB329C6.7040902@clear.net.nz> Thanks for the answers. I'm going with moving the subs and defining any required variables in main as "our". The outer sub is only executed once anyway (cgi web page), and any other fallout is almost certainly a bug. From grant at mclean.net.nz Wed Nov 9 12:35:20 2011 From: grant at mclean.net.nz (Grant McLean) Date: Thu, 10 Nov 2011 09:35:20 +1300 Subject: [Wellington-pm] Perl Weekly News Message-ID: <1320870920.26476.13.camel@putnam> Hi Mongers In case you've missed it, Gabor Szabo is producing a weekly email newsletter of links to Perl-related articles. It's also available on the web with an RSS feed. You can take a look and subscribe here: http://perlweekly.com/ This excerpt from the latest issue will strike a chord with some I'm sure: Presentazion - a DWIM slides HTML/JS software, with PDF export http://bit.ly/u0SKch Almost every Perl programmer who ever gave a presentation has written a system for creating slides. Some have done it more than once. This time Michele Beltrame (arthas) shares his own version. It looks simple and very nice and he shared the code as well. I think I'll rewrite mine now, based on ideas from his software :) See you at next Tuesday's meeting. http://wellington.pm.org/ Cheers Grant From grant at mclean.net.nz Sun Nov 13 15:44:37 2011 From: grant at mclean.net.nz (Grant McLean) Date: Mon, 14 Nov 2011 12:44:37 +1300 Subject: [Wellington-pm] Meeting tomorrow evening Message-ID: <1321227877.26570.4.camel@putnam> Hi Mongers The November meeting of Wellington Perl Mongers is tomorrow evening: 6:00pm Tuesday 15 November 2011 Level 7, Catalyst House 150 Willis Street Wellington http://wellington.pm.org/ We have two talks lined up: * Grant McLean - Mapping CPAN * Matthew Gray - Methods and Madness of Screen Scraping See you there. Grant From grant at mclean.net.nz Wed Nov 16 01:07:06 2011 From: grant at mclean.net.nz (Grant McLean) Date: Wed, 16 Nov 2011 22:07:06 +1300 Subject: [Wellington-pm] Roundup of last night's meeting Message-ID: <1321434426.3261.8.camel@hoiho> Hi Mongers It was another good turnout last night. I don't say it nearly often enough, but Catalyst deserve a big thank you for providing a venue and refreshments for our monthly meetings. I really appreciate the feedback and ideas people had for my Map of CPAN project. My slides are up on the web site archive and I'll let you know when I have something up you can play with. As I mentioned last night the schedule for the next 3 months has been well established by tradition: December - social meeting January - no meeting (enjoy your summer holidays everyone) February - Lightning talk meeting Stay tuned for details of venue for drinks and food in December. Please start thinking about what you could do a 5 minute talk about in February - you have 3 months to prepare so don't leave it till the last minute. Cheers Grant