From jdthornton at ozemail.com.au Sat Jan 3 01:56:52 2009 From: jdthornton at ozemail.com.au (John Thornton) Date: Sat, 3 Jan 2009 20:56:52 +1100 Subject: [Melbourne-pm] last thought on programming Message-ID: Last thought that I can't resist making. To explain why I still think that my school era [1980-1992] had "garbage" computer education, let me put it this way: Did you know that the Victorian curriculum has gone backwards in programming skills since the 80s? An outlandish claim? Well, I found Maths A and Maths B books in a hop shop. In the back of them were instructions for coding in Pascal!!! There was a list of Pascal commands! Where is that list [Java whatever] in today's maths books? Nowhere! The whole song and dance that the VCE is better than HSC at teaching people to apply maths to real life is bollocks. I have never bought the whole sales pitch that maths methods [It was change and approximation when I did VCE; methods came later] is so flipping fantastic at teaching applied maths skills. While we are at it I spare no savagery for the whole "info tech" subject either. I never did it. But it seems obvious to me that just as science is broken up [enviro tech, physics, chem. Etc] info tech should be broken up as well. There should be a subject where you take the computer physically apart and aother one where you program. To lump info tech as one subject is dumb dumb dumb. So that's what I think. Clearly my opinion of the VCE curriculum is pretty low. John -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjdean at bjdean.id.au Sat Jan 3 03:15:10 2009 From: bjdean at bjdean.id.au (Bradley Dean) Date: Sat, 3 Jan 2009 11:15:10 +0000 Subject: [Melbourne-pm] LWP/https timeout issue In-Reply-To: <20081230003457.GA19459@dwerryhouse.com.au> References: <20081230003457.GA19459@dwerryhouse.com.au> Message-ID: <20090103111504.GD13662@bjdean.id.au> Hi Paul, On Tue, Dec 30, 2008 at 11:34:57AM +1100, Paul Dwerryhouse wrote: > I've run across a small issue when using LWP with https connections, in that > it completely ignores the 'timeout' parameter. I've come across this sort of behaviour. As a I recall the problem is that the timeout is not measured across the entire request. Once a connection is established the timeout will trigger if there is a delay in data being sent by the server. The POD hints at this: " ... This means that the time it takes for the complete transaction and the request() method to actually return might be longer." > To complicate matters, I'm not calling LWP directly, but rather using it > via SOAP::Lite: > > $soap_conn = SOAP::Lite > ->uri('url:Blah::Handler') > ->proxy('https://localhost:81/blah',timeout => 5); > > $response = $soap_conn->function( > SOAP::Data->name('param' => 'whatever'))->result; My solution was to use SIGALRM (perldoc -f alarm) to force a timeout on the section of the code that made the request. Given that your request is inside SOAP::Lite this approach might also make sense because it's a timeout on the overall process, not just the HTTP request part. Cheerio, Brad -- Bradley Dean Software Engineer - http://bjdean.id.au/ Email: bjdean at bjdean.id.au Skype: skype at bjdean.id.au Mobile(Aus): +61-413014395 Mobile(UK): +44-7846895073 From toby.corkindale at strategicdata.com.au Sun Jan 4 16:39:06 2009 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Mon, 05 Jan 2009 11:39:06 +1100 Subject: [Melbourne-pm] last thought on programming In-Reply-To: References: Message-ID: <496156AA.906@strategicdata.com.au> John Thornton wrote: > Last thought that I can?t resist making. To explain why I > still think that my school era [1980-1992] had ?garbage? computer > education, let me put it this way: > > > > Did you know that the Victorian curriculum has gone > *backwards* in programming skills since the 80s? An outlandish claim? > Well, I found Maths A and Maths B books in a hop shop. In the back of > them were instructions for coding in Pascal!!! There was a list of > Pascal commands! Where is that list [Java whatever] in today?s maths > books? Nowhere! The whole song and dance that the VCE is better than HSC > at teaching people to apply maths to real life is bollocks. I have never > bought the whole sales pitch that maths methods [It was change and > approximation when I did VCE; methods came later] is so flipping > fantastic at teaching applied maths skills. In the 80s, high schools didn't really have any IT classes. If you were lucky enough to use a computer, you probably did it in your maths classes, since computers were really just elaborate programmable calculators as far as the curriculum people were concerned. Hence, the math textbooks have some programming info in them. Whereas today, the curriculum includes a dedicated ICT track: http://vels.vcaa.vic.edu.au/essential/interdisciplinary/ict/index.html So, it doesn't need to be squashed in with mathematics any longer, so it doesn't need to be in their textbooks. > While we are at it I spare no savagery for the whole ?info > tech? subject either. I never did it. But it seems obvious to me that > just as science is broken up [enviro tech, physics, chem. Etc] info tech > should be broken up as well. There should be a subject where you take > the computer physically apart and aother one where you program. To lump > info tech as one subject is dumb dumb dumb. People don't learn to take apart motorcycles or mobile phones in school. Why should they learn to take apart a computer? They are a commodity, consumer item, and the vast majority of people will treat it as such - they will purchase one, and when it breaks they will have a specialised worker repair it, or they will replace it. Just like their other consumer items. Why should we waste their time trying to teach them how to tell the difference between a GPU and a CPU? How many people can tell the difference between the fuel injector and spark plug in a modern engine, if they can even find them under the bonnet? Yet they can be perfectly fine drivers. -Toby From wayland at wayland.id.au Sun Jan 4 20:15:43 2009 From: wayland at wayland.id.au (Timothy S. Nelson) Date: Mon, 5 Jan 2009 15:15:43 +1100 (EST) Subject: [Melbourne-pm] last thought on programming In-Reply-To: <496156AA.906@strategicdata.com.au> References: <496156AA.906@strategicdata.com.au> Message-ID: On Mon, 5 Jan 2009, Toby Corkindale wrote: > John Thornton wrote: >> Last thought that I can?t resist making. To explain why I >> still think that my school era [1980-1992] had ?garbage? computer >> education, let me put it this way: >> >> Did you know that the Victorian curriculum has gone >> *backwards* in programming skills since the 80s? An outlandish claim? Well, >> I found Maths A and Maths B books in a hop shop. In the back of them were >> instructions for coding in Pascal!!! There was a list of Pascal commands! ...and DOS came with a built-in programming language (BASIC). Does Windows? I don't count batch files. >> While we are at it I spare no savagery for the whole ?info tech? >> subject either. I never did it. But it seems obvious to me that just as >> science is broken up [enviro tech, physics, chem. Etc] info tech should be >> broken up as well. There should be a subject where you take the computer >> physically apart and aother one where you program. To lump info tech as one >> subject is dumb dumb dumb. > > People don't learn to take apart motorcycles or mobile phones in school. Why > should they learn to take apart a computer? It seems to me that John is advocating a return to the old tech school/high school split (and I'd be happy with that). Having said that, I opened a friend's computer once, and his 9-year-old daughter looked over my shoulder and said "Where's the motherboard"? So it's too obvious to make a whole subject of, unless we're talking about an apprenticeship. But a class in "hardware problem solving" which incorporated computers and motorcycles and other things might be a useful idea. > They are a commodity, consumer item, and the vast majority of people will > treat it as such - they will purchase one, and when it breaks they will have > a specialised worker repair it, or they will replace it. Just like their > other consumer items. > > Why should we waste their time trying to teach them how to tell the > difference between a GPU and a CPU? How many people can tell the difference > between the fuel injector and spark plug in a modern engine, if they can even > find them under the bonnet? Yet they can be perfectly fine drivers. And mathematics beyond algebra is useful to people exactly how? I'm thinking here of geometry and trig and calculus. I'm not advocating that we stop teaching them or anything, but simply that it may be a more productive use of the nation's education resources to multi-stream. :) --------------------------------------------------------------------- | Name: Tim Nelson | Because the Creator is, | | E-mail: wayland at wayland.id.au | I am | --------------------------------------------------------------------- ----BEGIN GEEK CODE BLOCK---- Version 3.12 GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y- -----END GEEK CODE BLOCK----- From pjf at perltraining.com.au Sun Jan 4 21:17:04 2009 From: pjf at perltraining.com.au (Paul Fenwick) Date: Mon, 05 Jan 2009 16:17:04 +1100 Subject: [Melbourne-pm] Upcoming meeting dates and talks! (Next meeting: 14th Jan) Message-ID: <496197D0.2000302@perltraining.com.au> G'day MPM, Welcome to 2009. This year I'm hoping to have speakers and meetings organised well in advance. If you want to give a presentation, help organise a meeting, or hunt down new speakers, then let me (and preferably the list) know! Unless there are any objections, I'll be giving a sneak preview of my talk for Linux.conf.au at our first meeting. This is a full 40 minute talk: When: Wednesday, 14th January, 6:30pm Where: Remasys Pty Ltd Level 1 180 Flinders St MELBOURNE VIC 3121 Talk: Awesome things you've missed in Perl! (Paul Fenwick) (Full abstract at end of e-mail) I also had plans to give my "Art of Klingon Programming" talk at the second MPM meeting, but Linux Users Victoria (LUV) asked very nicely if they could see it to. As such, our second meeting for the year is combined with LUV: When: Tuesday, 3rd February Where: Buzzard Theatre Even Burge Building Trinity College Parkville VIC Map: http://luv.asn.au/meetings/map Talk: The Art of Klingon Programming (Paul Fenwick) Abstract at: http://wiki.osdcsydney.info/program/talk63 All the very best, Paul ---begin abstract--- Awesome things have been happening in Perl recently; so many that even if you've been paying close attention, you may have missed a few. In this talk we'll examine some of the coolest recent technologies for Perl programmers, including: * Overhauling Perl's Object Oriented framework with Moose. * Flexible, rapid, and painless web development with Catalyst. * Making everything a first-class object with autobox. * Slashing your error handling code with autodie. * Building fast, readable and reusable regular expressions with Perl 5.10. * Bundling and building stand-alone applications using PAR, the Perl Archiver. * Astonishingly good profiling with Devel::NYTProf. * Playing MineSweeper automatically with App::SweeperBot. Knowledge of Perl is nice, but not essential to appreciate the contents of this talk. ---end abstract--- -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From alec.clews at gmail.com Sun Jan 4 23:46:24 2009 From: alec.clews at gmail.com (Alec Clews) Date: Mon, 05 Jan 2009 18:46:24 +1100 Subject: [Melbourne-pm] Upcoming meeting dates and talks! (Next meeting: 14th Jan) In-Reply-To: <496197D0.2000302@perltraining.com.au> References: <496197D0.2000302@perltraining.com.au> Message-ID: <4961BAD0.8050705@gmail.com> Given Perl's migration to git it may be opportune to have some git presentations? I'd be happy to demo github.com (simple 20 mins) Paul Fenwick wrote: > G'day MPM, > > Welcome to 2009. This year I'm hoping to have speakers and meetings > organised well in advance. If you want to give a presentation, help > organise a meeting, or hunt down new speakers, then let me (and preferably > the list) know! > > Unless there are any objections, I'll be giving a sneak preview of my talk > for Linux.conf.au at our first meeting. This is a full 40 minute talk: > > When: Wednesday, 14th January, 6:30pm > > Where: Remasys Pty Ltd > Level 1 > 180 Flinders St > MELBOURNE VIC 3121 > > Talk: Awesome things you've missed in Perl! (Paul Fenwick) > (Full abstract at end of e-mail) > > I also had plans to give my "Art of Klingon Programming" talk at the second > MPM meeting, but Linux Users Victoria (LUV) asked very nicely if they could > see it to. As such, our second meeting for the year is combined with LUV: > > When: Tuesday, 3rd February > > Where: Buzzard Theatre > Even Burge Building > Trinity College > Parkville VIC > > Map: http://luv.asn.au/meetings/map > > Talk: The Art of Klingon Programming (Paul Fenwick) > Abstract at: http://wiki.osdcsydney.info/program/talk63 > > All the very best, > > Paul > > ---begin abstract--- > > Awesome things have been happening in Perl recently; so many that even if > you've been paying close attention, you may have missed a few. In this talk > we'll examine some of the coolest recent technologies for Perl programmers, > including: > > * Overhauling Perl's Object Oriented framework with Moose. > > * Flexible, rapid, and painless web development with Catalyst. > > * Making everything a first-class object with autobox. > > * Slashing your error handling code with autodie. > > * Building fast, readable and reusable regular expressions with Perl 5.10. > > * Bundling and building stand-alone applications using PAR, the > Perl Archiver. > > * Astonishingly good profiling with Devel::NYTProf. > > * Playing MineSweeper automatically with App::SweeperBot. > > Knowledge of Perl is nice, but not essential to appreciate the contents of > this talk. > > ---end abstract--- > > From ts at meme.com.au Mon Jan 5 18:09:38 2009 From: ts at meme.com.au (Tony Smith) Date: Tue, 6 Jan 2009 13:09:38 +1100 Subject: [Melbourne-pm] Upcoming meeting dates and talks! (Next meeting: 14th Jan) In-Reply-To: <496197D0.2000302@perltraining.com.au> References: <496197D0.2000302@perltraining.com.au> Message-ID: As mentioned in December, I'm keen to present the Perl scripting capability built into the cellular automata platform Golly 2.0 (which I was able to announce the release of in a lightning talk at OSDC). Can be as long or short as needed with a few days notice for final preparation. On 05/01/2009, at 4:17 PM, Paul Fenwick wrote: > Welcome to 2009. This year I'm hoping to have speakers and meetings > organised well in advance. If you want to give a presentation, help > organise a meeting, or hunt down new speakers, then let me (and > preferably > the list) know! Tony Smith Complex Systems Analyst Meme Media Melbourne, Australia http://www.meme.com.au/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pjf at perltraining.com.au Mon Jan 5 19:40:54 2009 From: pjf at perltraining.com.au (Paul Fenwick) Date: Tue, 06 Jan 2009 14:40:54 +1100 Subject: [Melbourne-pm] Upcoming meeting dates and talks! (Next meeting: 14th Jan) In-Reply-To: References: <496197D0.2000302@perltraining.com.au> Message-ID: <4962D2C6.5080309@perltraining.com.au> G'day MPM / Alec / Tony, Alec Clews wrote: > Given Perl's migration to git it may be opportune to have some git > presentations? > > I'd be happy to demo github.com (simple 20 mins) Tony Smith wrote: > As mentioned in December, I'm keen to present the Perl scripting > capability built into the cellular automata platform Golly 2.0 (which I > was able to announce the release of in a lightning talk at OSDC). Can be > as long or short as needed with a few days notice for final preparation. Brilliant! Tentatively the schedule looks like: * January: Awesome things you've missed in Perl (PJF) * February: The Art of Klingon Programming (PJF) * March: An introduction to git and github.com (Alec) * April: Perl scripting in Golly 2.0 (Tony) I've also got a 25 minute presentation from Jacinta (with video demonstrations) on a comparison of MVC frameworks (Catalyst, Jifty, Gantry and Maypole) that we can slot into May, or combine with a shorter talk. I've been updating http://perl.net.au/wiki/MPM with the new info, and have just added these details to the 2009 meetings page. Redesign and editing of the MPM page on perl.net.au is very welcome and appreciated, and *anyone* can edit. Many thanks, and all the best, Paul -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From pjf at perltraining.com.au Mon Jan 5 20:00:11 2009 From: pjf at perltraining.com.au (Paul Fenwick) Date: Tue, 06 Jan 2009 15:00:11 +1100 Subject: [Melbourne-pm] Upcoming meeting dates and talks! (Next meeting: 14th Jan) In-Reply-To: <4962D2C6.5080309@perltraining.com.au> References: <496197D0.2000302@perltraining.com.au> <4962D2C6.5080309@perltraining.com.au> Message-ID: <4962D74B.9030308@perltraining.com.au> Paul Fenwick wrote: > Brilliant! Tentatively the schedule looks like: > > * January: Awesome things you've missed in Perl (PJF) > * February: The Art of Klingon Programming (PJF) > * March: An introduction to git and github.com (Alec) > * April: Perl scripting in Golly 2.0 (Tony) I've been reminded that Melbourne.pm is hosting OSDClub in April. Since git is a language agnostic revision control system, so I'm going to swap Tony and Alec's talks around. The new schedule looks like: * January: Awesome things you've missed in Perl (PJF) * February: The Art of Klingon Programming (PJF, with LUV) * March: Perl scripting in Golly 2.0 (Tony) * April: An introduction to git and github.com (Alec, with OSDClub) Cheerio, Paul -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From Nathan.Bailey at its.monash.edu Wed Jan 7 17:26:58 2009 From: Nathan.Bailey at its.monash.edu (Nathan Bailey) Date: Thu, 08 Jan 2009 12:26:58 +1100 Subject: [Melbourne-pm] LifeHacker meeting? (Was: Upcoming meeting dates and talks!) In-Reply-To: <496197D0.2000302@perltraining.com.au> References: <496197D0.2000302@perltraining.com.au> Message-ID: <9F5E8B9E-42C7-4228-8C16-84EBE793F185@its.monash.edu> Is there any interest in doing a "LifeHacker" meeting, where a bunch of us do lighting talks about how we manage our productivity using tools, scripts, files and personal procedures and processes? (cf. your talk on BeeHive(?) Paul?). re, N On 05/01/2009, at 4:17 PM, Paul Fenwick wrote: > G'day MPM, > > Welcome to 2009. This year I'm hoping to have speakers and meetings > organised well in advance. If you want to give a presentation, help > organise a meeting, or hunt down new speakers, then let me (and > preferably > the list) know! > > Unless there are any objections, I'll be giving a sneak preview of > my talk > for Linux.conf.au at our first meeting. This is a full 40 minute > talk: > > When: Wednesday, 14th January, 6:30pm > > Where: Remasys Pty Ltd > Level 1 > 180 Flinders St > MELBOURNE VIC 3121 > > Talk: Awesome things you've missed in Perl! (Paul Fenwick) > (Full abstract at end of e-mail) > > I also had plans to give my "Art of Klingon Programming" talk at the > second > MPM meeting, but Linux Users Victoria (LUV) asked very nicely if > they could > see it to. As such, our second meeting for the year is combined > with LUV: > > When: Tuesday, 3rd February > > Where: Buzzard Theatre > Even Burge Building > Trinity College > Parkville VIC > > Map: http://luv.asn.au/meetings/map > > Talk: The Art of Klingon Programming (Paul Fenwick) > Abstract at: http://wiki.osdcsydney.info/program/talk63 > > All the very best, > > Paul > > ---begin abstract--- > > Awesome things have been happening in Perl recently; so many that > even if > you've been paying close attention, you may have missed a few. In > this talk > we'll examine some of the coolest recent technologies for Perl > programmers, > including: > > * Overhauling Perl's Object Oriented framework with Moose. > > * Flexible, rapid, and painless web development with Catalyst. > > * Making everything a first-class object with autobox. > > * Slashing your error handling code with autodie. > > * Building fast, readable and reusable regular expressions with Perl > 5.10. > > * Bundling and building stand-alone applications using PAR, the > Perl Archiver. > > * Astonishingly good profiling with Devel::NYTProf. > > * Playing MineSweeper automatically with App::SweeperBot. > > Knowledge of Perl is nice, but not essential to appreciate the > contents of > this talk. > > ---end abstract--- > > -- > Paul Fenwick | http://perltraining.com.au/ > Director of Training | Ph: +61 3 9354 6001 > Perl Training Australia | Fax: +61 3 9354 2681 > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm From melbourne.pm at joshheumann.com Wed Jan 7 20:07:04 2009 From: melbourne.pm at joshheumann.com (Josh Heumann) Date: Wed, 7 Jan 2009 20:07:04 -0800 Subject: [Melbourne-pm] LifeHacker meeting? (Was: Upcoming meeting dates and talks!) In-Reply-To: <9F5E8B9E-42C7-4228-8C16-84EBE793F185@its.monash.edu> References: <496197D0.2000302@perltraining.com.au> <9F5E8B9E-42C7-4228-8C16-84EBE793F185@its.monash.edu> Message-ID: <20090108040704.GB24055@joshheumann.com> > Is there any interest in doing a "LifeHacker" meeting, where a bunch > of us do lighting talks about how we manage our productivity using > tools, scripts, files and personal procedures and processes? (cf. your > talk on BeeHive(?) Paul?). I'd be interested in a Life Hacker-type meeting. I have a few ways I attempt to keep things in order that I'd be happy to share. It's probably a separate, non-perl-specific meeting, though. I'd also love to hear if anyone can give a ringing endorsement of any of the millions of ways of Getting Things Done(tm), either online like Hiveminder, or locally sich as iGTD (which I keep meaning to play with, but can never be convinced that it's any better than what I'm doing now). J From pjf at perltraining.com.au Thu Jan 8 05:22:17 2009 From: pjf at perltraining.com.au (Paul Fenwick) Date: Fri, 09 Jan 2009 00:22:17 +1100 Subject: [Melbourne-pm] LifeHacker meeting? (Was: Upcoming meeting dates and talks!) In-Reply-To: <20090108040704.GB24055@joshheumann.com> References: <496197D0.2000302@perltraining.com.au> <9F5E8B9E-42C7-4228-8C16-84EBE793F185@its.monash.edu> <20090108040704.GB24055@joshheumann.com> Message-ID: <4965FE09.8040906@perltraining.com.au> G'day Josh / MPM, Josh Heumann wrote: > I'd be interested in a Life Hacker-type meeting. I have a few ways I > attempt to keep things in order that I'd be happy to share. It's > probably a separate, non-perl-specific meeting, though. It'd be perfect for an OSDClub meeting. ;) Cheerio, Paul -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From jarich at perltraining.com.au Mon Jan 12 04:02:47 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 12 Jan 2009 23:02:47 +1100 Subject: [Melbourne-pm] Perl meeting next week in Hobart (at LCA)? Message-ID: <496B3167.30106@perltraining.com.au> G'day folk, I'm posting this to the Melbourne and Sydney Perl Monger groups because I know that there are a lot of non Melbourne and Sydney folk from around Australia who hang out on these two lists for the company. Tonight I'm particularly looking for Perl programmers who reside in Hobart. Next week linux.conf.au (LCA) is running in Hobart. I'm not sure how big the Perl scene is in Hobart, but I'm hoping it's big enough to support a Perl Mongers group. As a result, I'd like to take advantage of LCA's drawing power, and arrange a Perl BOF for all the locals (and visitors) and perhaps kick-start Hobart Perl Mongers. My plan is to run it in the evening of Monday 19th January (this means it doesn't clash with any other of the social events). If you'll be in Hobart (and especially if you're local) I'd love to hear from you. I was thinking that - depending on numbers - it might be good to run a semi-formal session with 10 or so lightning talks followed by a social dinner or drink. Please let me know which (if any) of the following categories you fit into: a) You're local b) You'd be interested in participating in Hobart Perl Mongers if it started up c) You'd be interested in managing Hobart Perl Mongers if it started up[1] d) You'd like to give a lightning talk e) You'd be interested in just turning up Also, please let me know your availability at the following times (with the understanding that no time I pick will be perfect, so flexibility on your behalf will be awesome): Monday evening (19th Jan) Tuesday evening (may clash with Speakers dinner) Wednesday lunch time Thursday lunch time Thursday evening (may clash with the PDNS) Friday lunch time I am particularly partial to having it on the Monday evening. Many thanks, and I'd love to get this going. Jacinta [1]. Duties of a Perl Mongers Group Leader are to: a) Register group with groups.pm.org and fill out the occasional (every 2-3 years) census b) Create and maintain the website c) Expunge moderated (usually spam) mail from the mailing list at least yearly It would be nice if you organised the occasional (yearly or so) meeting, but it's not actually required. From lsharpe at pacificwireless.com.au Mon Jan 12 16:17:52 2009 From: lsharpe at pacificwireless.com.au (Leigh Sharpe) Date: Tue, 13 Jan 2009 11:17:52 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects Message-ID: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> Hi All, I'm working on a TK app, and I'm struggling with a few things. I have a function which looks a bit like this: sub new_object { my $object=My::Class->new(); # Create a new object to monitor my $tl=$mw->Toplevel; # Create a top-level window. $tl->title($object->{'name'}); # Set the title of the new window. $tl->Label(-text=>"Name:")->grid(-row=>0, -column=>0); # Add Labels to window. $tl->Label(-textvariable=>\$object->{'name'})->grid(-row=>0, -column=>1); $tl->Label(-text=>"IP Address")->grid(-row=>1, -column=>0); $tl->Label(-textvariable=>\$object->{'ip'})->grid(-row=>1, -column=>1); $tl->Label(-text=>"Uptime:")->grid(-row=>2, -column=>0); $tl->Label(-textvariable=>\$object->{'uptime'})->grid(-row=>2, -column=>1); $tl->Button(-text=>"Exit", -command=>sub{$tl->destroy()})->grid(-row=>20, -column=>0); # Create an exit button. $tl->repeat(5000, sub{$object->update_status()}); # Update the status every 5 seconds. } Now this works as it is, but I just know it won't scale well. I would rather have a single class method I could call which would run update_status() on all objects of it's class, and call it from the main window ($mw in this case). So my first question is, how can a class access all instances of itself? I considered creating an array in which I could store a reference to all objects, but that just seems wrong, 'cause it will prevent objects from going out of scope when all other references to them are deleted. The second question is in relation to keeping $object in scope. If I remove the last line of the above function, $object goes out of scope as soon as the function completes. Having a label with -textvariable=>\$object{'anything'} isn't sufficient to keep $object in scope. So, if I was to create a class method as required, there would be no objects to call update_status() on. However, with the function as it is above, even destroying $tl (when the user clicks on the 'Exit' button) doesn't call DESTROY on $object. There must be some reference to the object somewhere, created by $tl->repeat(), which isn't going out of scope when $tl is destroy()ed. Anybody care to shed some light on this? Regards, Leigh Leigh Sharpe Network Systems Engineer Pacific Wireless Ph +61 3 9584 8966 Mob 0408 009 502 Helpdesk 1300 300 616 email lsharpe at pacificwireless.com.au web www.pacificwireless.com.au -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathew.robertson at netratings.com.au Mon Jan 12 16:36:03 2009 From: mathew.robertson at netratings.com.au (Mathew Robertson) Date: Tue, 13 Jan 2009 11:36:03 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> Message-ID: <496BE1F3.5060309@netratings.com.au> Leigh Sharpe wrote: > Hi All, > I'm working on a TK app, and I'm struggling with a few things. > I have a function which looks a bit like this: > > sub new_object > { > my $object=My::Class->new(); # Create a new object to monitor > my $tl=$mw->Toplevel; # Create a top-level window. > $tl->title($object->{'name'}); # Set the title of the > new window. > $tl->Label(-text=>"Name:")->grid(-row=>0, -column=>0); # Add Labels > to window. > $tl->Label(-textvariable=>\$object->{'name'})->grid(-row=>0, -column=>1); > $tl->Label(-text=>"IP Address")->grid(-row=>1, -column=>0); > $tl->Label(-textvariable=>\$object->{'ip'})->grid(-row=>1, -column=>1); > $tl->Label(-text=>"Uptime:")->grid(-row=>2, -column=>0); > $tl->Label(-textvariable=>\$object->{'uptime'})->grid(-row=>2, > -column=>1); > $tl->Button(-text=>"Exit", > -command=>sub{$tl->destroy()})->grid(-row=>20, -column=>0); # Create > an exit button. > $tl->repeat(5000, sub{$object->update_status()}); # Update the status > every 5 seconds. > } > > Now this works as it is, but I just know it won't scale well. I would > rather have a single class method I could call which would run > update_status() on all objects of it's class, and call it from the > main window ($mw in this case). So my first question is, how can a > class access all instances of itself? I considered creating an array > in which I could store a reference to all objects, but that just seems > wrong, 'cause it will prevent objects from going out of scope when all > other references to them are deleted. I'm assuming that this new_object function is in the package "Package::Blah". If not, then it probably should be. So: package Package::Blah; our $SOMEVARIABLE; then in your other code: $Package::Blah::SOMEVARIABLE = "fred"; ie: just refer to the full package name. > > The second question is in relation to keeping $object in scope. If I > remove the last line of the above function, $object goes out of scope > as soon as the function completes. Having a label with > -textvariable=>\$object{'anything'} isn't sufficient to keep $object > in scope. Then you need to keep a package reference to it, eg in Package::Blah: our @SOMELIST; push @SOMELIST, $object; > So, if I was to create a class method as required, there would be no > objects to call update_status() on. map { $_->update() } @Package::Blah::SOMELIST; > However, with the function as it is above, even destroying $tl (when > the user clicks on the 'Exit' button) doesn't call DESTROY on $object. > There must be some reference to the object somewhere, created by > $tl->repeat(), which isn't going out of scope when $tl is destroy()ed. Are you sure its not being destroyed? cheers, Mathew -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarich at perltraining.com.au Mon Jan 12 17:23:22 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Tue, 13 Jan 2009 12:23:22 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> Message-ID: <496BED0A.5050007@perltraining.com.au> G'day Leigh, Leigh Sharpe wrote: > sub new_object > { > my $object=My::Class->new(); # Create a new object to monitor > my $tl=$mw->Toplevel; # Create a top-level window. > $tl->title($object->{'name'}); # Set the title of the > new window. > $tl->Label(-text=>"Name:")->grid(-row=>0, -column=>0); # Add Labels to > window. > $tl->Label(-textvariable=>\$object->{'name'})->grid(-row=>0, -column=>1); > $tl->Label(-text=>"IP Address")->grid(-row=>1, -column=>0); > $tl->Label(-textvariable=>\$object->{'ip'})->grid(-row=>1, -column=>1); > $tl->Label(-text=>"Uptime:")->grid(-row=>2, -column=>0); > $tl->Label(-textvariable=>\$object->{'uptime'})->grid(-row=>2, -column=>1); > $tl->Button(-text=>"Exit", > -command=>sub{$tl->destroy()})->grid(-row=>20, -column=>0); # Create an > exit button. > $tl->repeat(5000, sub{$object->update_status()}); # Update the status > every 5 seconds. > } > Now this works as it is, but I just know it won't scale well. I would > rather have a single class method I could call which would run > update_status() on all objects of it's class, and call it from the main > window ($mw in this case). So my first question is, how can a class > access all instances of itself? I considered creating an array in which > I could store a reference to all objects, but that just seems wrong, > 'cause it will prevent objects from going out of scope when all other > references to them are deleted. You can create an array of all the objects and then weaken those references so that the object will still be cleaned up upon going out of scope. You then want to make sure that you handle holes in your array. For example: # Weak.pm package Weak; use strict; use Scalar::Util qw(weaken); my @all_objects; sub new { my ($class, $name) = @_; my $self = { name => $name }; $self = bless $self, $class; # Add reference to object to array push @all_objects, $self; # Weaken reference so that it doesn't count for garbage # collection weaken $all_objects[-1]; return $self; } sub update_all { my ($class, @args) = @_; foreach my $self (@all_objects) { # Skip if it's empty or looks funny next unless ($self and ref $self eq $class); print $self->{name}, "\n"; } } 1; # Test script use strict; use Weak; my $object1 = Weak->new("obj1"); my $object2 = Weak->new("obj2"); { # Object 3 is only in this scope my $object3 = Weak->new("obj3"); # Should print out 1 - 3. Weak->update_all(); } # One last object my $object4 = Weak->new("obj4"); print "\n\n"; Weak->update_all(); __END__ obj1 obj2 obj3 obj1 obj2 obj4 Still, I can't but think that you might be approaching the problem the wrong way. I'd need to know more about what you're doing in order to suggest a better answer. > The second question is in relation to keeping $object in scope. If I > remove the last line of the above function, $object goes out of scope as > soon as the function completes. Having a label with > -textvariable=>\$object{'anything'} isn't sufficient to keep $object in > scope. Is there a reason you're not returning your object? It seems odd to worry about whether objects can properly be cleaned up when going out of scope (as you mentioned above) and then not actually pass them back into the program so that you can use them in the scope for which you've created them. I haven't done a lot of TK programming, so maybe that's where I'm missing this, but usually one creates an object, and passes it out to the code that wanted to use it, and then when it goes out of scope naturally it's cleaned up.... > So, if I was to create a class method as required, there would be no > objects to call update_status() on. > However, with the function as it is above, even destroying $tl (when the > user clicks on the 'Exit' button) doesn't call DESTROY on $object. There > must be some reference to the object somewhere, created by > $tl->repeat(), which isn't going out of scope when $tl is destroy()ed. This doesn't seem right. In your new_object sub you create $object and it can be accessed by that name. After that sub has finished $object can still be accessed by $tl's argument to repeat. Once $tl has been cleaned up, unless it has stored that subroutine some other way, the anonymous subroutine cannot be accessed so it should be cleaned up and then $object cannot be accessed so it should be cleaned up. Add a DESTROY method to your class and see what's going on, because I'd expect it to be cleaned up. For example: sub DESTROY { my ($self) = @_; print $self->{name}, " is being destroyed\n"; } All the best, J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From lsharpe at pacificwireless.com.au Mon Jan 12 18:08:50 2009 From: lsharpe at pacificwireless.com.au (Leigh Sharpe) Date: Tue, 13 Jan 2009 13:08:50 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> Message-ID: <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> Hi Jacinta, >You can create an array of all the objects and then weaken those references so that the object will still be >cleaned up upon going out of scope. You then want to make sure that you handle holes in your array. For >example: Thanks, that looks like the answer I'm after. Perhaps, however, I didn't explain my problem clearly enough: >Is there a reason you're not returning your object? It seems odd to worry about whether objects can properly be >cleaned up when going out of scope (as you mentioned above) and then not actually pass them back into the >program so that you can use them in the scope for which you've created them. I am returning an object. The function I had in my original email was not in my package, it was in main. Here's a working example of what I'm experiencing: in My_Package.pm: ----- #!c:\perl\bin\perl use strict; use warnings; package My::Class; sub new { my $class=shift; # Get the class we have been called with. my $self={}; # Create anonymous hash to bless. $self->{'name'}="fred"; $self->{'uptime'}=1; # And some other initialisation here. bless $self, $class; # Bless the object into the correct namespace. return $self; # Return the newly-blessed object. } sub update_status { my $self=shift; $self->{'uptime'}++; return 1; } sub DESTROY { my ($self) = @_; print $self->{name}, " is being destroyed\n"; } 1; ----- Nothing difficult in there. Now, in my application: ---- use strict; use warnings; use Net::SNMP; use Tk; use My_Package; my $mw=MainWindow->new(-title=>"Leigh's Test App") or die "Can't create main window: $!\n"; # Create the main window object. my $exit_button=$mw->Button( -command=>sub{$mw->destroy()}, -text=>"Exit"); # Create the exit button. my $add_button=$mw->Button(-command=>\&new_object, -text=>"Create an object."); $exit_button->pack(-side=>'bottom'); $add_button->pack(); MainLoop; sub new_object { my $object=My::Class->new(); # Create a new object to monitor my $tl=$mw->Toplevel; # Create a top-level window. $tl->title($object->{'name'}); # Set the title of the new window. $tl->Label(-text=>"Name:")->grid(-row=>0, -column=>0); # Add Labels to window. $tl->Label(-textvariable=>\$object->{'name'})->grid(-row=>0, -column=>1); $tl->Label(-text=>"IP Address")->grid(-row=>1, -column=>0); $tl->Label(-textvariable=>\$object->{'ip'})->grid(-row=>1, -column=>1); $tl->Label(-text=>"Uptime:")->grid(-row=>2, -column=>0); $tl->Label(-textvariable=>\$object->{'uptime'})->grid(-row=>2, -column=>1); $tl->Button(-text=>"Exit", -command=>sub{$tl->destroy()})->grid(-row=>20, -column=>0); # Create an exit button. $tl->repeat(5000, sub{$object->update_status()}); # Update the status every 5 seconds. } --------- I simply create a window with two buttons. One is an exit button, and one calls new_object() when it is clicked. new_object() calls new() on My::Class, which returns the newly created object. Here's the bit I couldn't quite understand. My::Class::DESTROY() is not called when the 'Exit' button on $tl is clicked. If I click on 'Create an object' several times, and close any or all of the windows it creates, there is no message printed when the window is closed. Only when I click on 'Exit' in the main window, thereby terminating the whole program, do I ever see DESTROY() called. And then it's once for every object created while the program was running, irrespective of whether it's window has been closed or not. Try it, the above example is complete. This may be all irrelevant, however, as it looks like you've already given me the answer I was after. This is, to me anyway, strange behaviour from Tk, but I should be able to avoid it by keeping an array and weakening the references in it. Regards, Leigh Leigh Sharpe Network Systems Engineer Pacific Wireless Ph +61 3 9584 8966 Mob 0408 009 502 Helpdesk 1300 300 616 email lsharpe at pacificwireless.com.au web www.pacificwireless.com.au -----Original Message----- From: Jacinta Richardson [mailto:jarich at perltraining.com.au] Sent: Tuesday, 13 January 2009 12:23 PM To: Leigh Sharpe Cc: melbourne-pm at pm.org Subject: Re: [Melbourne-pm] TK repeats, scoping and keeping track of objects G'day Leigh, Leigh Sharpe wrote: > sub new_object > { > my $object=My::Class->new(); # Create a new object to monitor > my $tl=$mw->Toplevel; # Create a top-level window. > $tl->title($object->{'name'}); # Set the title of the > new window. > $tl->Label(-text=>"Name:")->grid(-row=>0, -column=>0); # Add Labels > to window. > $tl->Label(-textvariable=>\$object->{'name'})->grid(-row=>0, > -column=>1); $tl->Label(-text=>"IP Address")->grid(-row=>1, > -column=>0); > $tl->Label(-textvariable=>\$object->{'ip'})->grid(-row=>1, > -column=>1); $tl->Label(-text=>"Uptime:")->grid(-row=>2, -column=>0); > $tl->Label(-textvariable=>\$object->{'uptime'})->grid(-row=>2, > -column=>1); $tl->Button(-text=>"Exit", > -command=>sub{$tl->destroy()})->grid(-row=>20, -column=>0); # Create an exit button. > $tl->repeat(5000, sub{$object->update_status()}); # Update the status > every 5 seconds. > } > Now this works as it is, but I just know it won't scale well. I would > rather have a single class method I could call which would run > update_status() on all objects of it's class, and call it from the > main window ($mw in this case). So my first question is, how can a > class access all instances of itself? I considered creating an array > in which I could store a reference to all objects, but that just seems > wrong, 'cause it will prevent objects from going out of scope when all > other references to them are deleted. You can create an array of all the objects and then weaken those references so that the object will still be cleaned up upon going out of scope. You then want to make sure that you handle holes in your array. For example: # Weak.pm package Weak; use strict; use Scalar::Util qw(weaken); my @all_objects; sub new { my ($class, $name) = @_; my $self = { name => $name }; $self = bless $self, $class; # Add reference to object to array push @all_objects, $self; # Weaken reference so that it doesn't count for garbage # collection weaken $all_objects[-1]; return $self; } sub update_all { my ($class, @args) = @_; foreach my $self (@all_objects) { # Skip if it's empty or looks funny next unless ($self and ref $self eq $class); print $self->{name}, "\n"; } } 1; # Test script use strict; use Weak; my $object1 = Weak->new("obj1"); my $object2 = Weak->new("obj2"); { # Object 3 is only in this scope my $object3 = Weak->new("obj3"); # Should print out 1 - 3. Weak->update_all(); } # One last object my $object4 = Weak->new("obj4"); print "\n\n"; Weak->update_all(); __END__ obj1 obj2 obj3 obj1 obj2 obj4 Still, I can't but think that you might be approaching the problem the wrong way. I'd need to know more about what you're doing in order to suggest a better answer. > The second question is in relation to keeping $object in scope. If I > remove the last line of the above function, $object goes out of scope > as soon as the function completes. Having a label with > -textvariable=>\$object{'anything'} isn't sufficient to keep $object > in scope. Is there a reason you're not returning your object? It seems odd to worry about whether objects can properly be cleaned up when going out of scope (as you mentioned above) and then not actually pass them back into the program so that you can use them in the scope for which you've created them. I haven't done a lot of TK programming, so maybe that's where I'm missing this, but usually one creates an object, and passes it out to the code that wanted to use it, and then when it goes out of scope naturally it's cleaned up.... > So, if I was to create a class method as required, there would be no > objects to call update_status() on. > However, with the function as it is above, even destroying $tl (when > the user clicks on the 'Exit' button) doesn't call DESTROY on $object. > There must be some reference to the object somewhere, created by > $tl->repeat(), which isn't going out of scope when $tl is destroy()ed. This doesn't seem right. In your new_object sub you create $object and it can be accessed by that name. After that sub has finished $object can still be accessed by $tl's argument to repeat. Once $tl has been cleaned up, unless it has stored that subroutine some other way, the anonymous subroutine cannot be accessed so it should be cleaned up and then $object cannot be accessed so it should be cleaned up. Add a DESTROY method to your class and see what's going on, because I'd expect it to be cleaned up. For example: sub DESTROY { my ($self) = @_; print $self->{name}, " is being destroyed\n"; } All the best, J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From toby.corkindale at strategicdata.com.au Mon Jan 12 18:30:45 2009 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 13 Jan 2009 13:30:45 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> Message-ID: <496BFCD5.9080505@strategicdata.com.au> Leigh Sharpe wrote: > Hi Jacinta, > > >> You can create an array of all the objects and then weaken those > references so that the object will still be >> cleaned up upon going out of scope. You then want to make sure that > you handle holes in your array. For >> example: > > Thanks, that looks like the answer I'm after. > > Perhaps, however, I didn't explain my problem clearly enough: > >> Is there a reason you're not returning your object? It seems odd to > worry about whether objects can properly be >> cleaned up when going out of scope (as you mentioned above) and then > not actually pass them back into the >> program so that you can use them in the scope for which you've created > them. > > I am returning an object. The function I had in my original email was > not in my package, it was in main. Here's a working example of what I'm > experiencing: [snip] I note that the Tk docs state: "Note however that while a window exists for $widget the perl object is maintained (due to "references" in perl/Tk internals) even though original variables may have gone out of scope. (Normally this is intuitive.)" I suggest you look at the OnDestroy() callback instead of relying on the Perl garbage collection here. -Toby From toby.corkindale at strategicdata.com.au Mon Jan 12 18:36:39 2009 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 13 Jan 2009 13:36:39 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <496BFCD5.9080505@strategicdata.com.au> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> <496BFCD5.9080505@strategicdata.com.au> Message-ID: <496BFE37.3040805@strategicdata.com.au> Toby Corkindale wrote: > Leigh Sharpe wrote: >> Hi Jacinta, >> >> >>> You can create an array of all the objects and then weaken those >> references so that the object will still be >>> cleaned up upon going out of scope. You then want to make sure that >> you handle holes in your array. For >>> example: >> >> Thanks, that looks like the answer I'm after. >> >> Perhaps, however, I didn't explain my problem clearly enough: >> >>> Is there a reason you're not returning your object? It seems odd to >> worry about whether objects can properly be >>> cleaned up when going out of scope (as you mentioned above) and then >> not actually pass them back into the >>> program so that you can use them in the scope for which you've created >> them. >> I am returning an object. The function I had in my original email was >> not in my package, it was in main. Here's a working example of what I'm >> experiencing: > > [snip] > I note that the Tk docs state: > "Note however that while a window exists for $widget the perl object is > maintained (due to "references" in perl/Tk internals) even though > original variables may have gone out of scope. (Normally this is > intuitive.)" > > I suggest you look at the OnDestroy() callback instead of relying on the > Perl garbage collection here. See attached for a quick demo, which seems to have the desired behaviour: $ ./tkdemo.pl new mainWindow opened.. at ./tkdemo.pl line 25. # I click 'about' new About dialog opened.. at ./tkdemo.pl line 48. # I click 'close' About->close button pressed at ./tkdemo.pl line 40. myDestroy called, and left a voicemail. at ./tkdemo.pl line 59. Destroy called.. and hung-up on me. at ./tkdemo.pl line 54. # I click 'About' again.. new About dialog opened.. at ./tkdemo.pl line 48. # and close it again.. About->close button pressed at ./tkdemo.pl line 40. myDestroy called, and left a voicemail. at ./tkdemo.pl line 59. Destroy called.. and hung-up on me. at ./tkdemo.pl line 54. # now I close the main window mainWindow->close button pressed at ./tkdemo.pl line 21. -------------- next part -------------- A non-text attachment was scrubbed... Name: tkdemo.pl Type: application/x-perl Size: 1285 bytes Desc: not available URL: From jarich at perltraining.com.au Mon Jan 12 18:48:02 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Tue, 13 Jan 2009 13:48:02 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> Message-ID: <496C00E2.2070604@perltraining.com.au> I've embedded my comments in your code (after a little reformatting). For what it's worth, the common place to see comments regarding a line of code is above that line, not below. I realise you've generally put them at the end, but - at least to me - this only works for short lines. Otherwise putting them at the end hides them off the side of the window without wrapping or hides them amongst code when the line wraps (and makes perltidy sad too). I've moved comments on long lines up to above the line they refer to. It's a comment on style; of course you should be consistent with whatever style guidelines your workplace has specified. ;) > in My_Package.pm: > ----- > #!c:\perl\bin\perl #! lines are not required for modules (and are probably best omitted). > use strict; > use warnings; > > package My::Class; Ideally, your package line should be the first line in your file, and all use statements should come after it. For strict and warnings this isn't a problem, but if you were to "use base qw(Exporter);" (for example) above your package line, then that would almost certainly not have the desired effect. > sub new { > my $class = shift; > > # Get the class we have been called with. > my $self = {}; > > # Create anonymous hash to bless. > $self->{'name'} = "fred"; > $self->{'uptime'} = 1; > > # And some other initialisation here. > bless $self, $class; > > # Bless the object into the correct namespace. > return $self; > > # Return the newly-blessed object. > } > > sub update_status { > my $self = shift; > $self->{'uptime'}++; > return 1; > } > > sub DESTROY { > my ($self) = @_; > print $self->{name}, " is being destroyed\n"; > } > > 1; > > ----- > Nothing difficult in there. Now, in my application: > ---- A shebang line here wouldn't go astray. > use strict; > use warnings; > use Net::SNMP; > use Tk; > use My_Package; > > # Create the main window object. > my $mw = MainWindow->new( -title => "Leigh's Test App" ) > or die "Can't create main window: $!\n"; > > # Create the exit button. > my $exit_button = $mw->Button( > -command => sub { $mw->destroy() }, > -text => "Exit" > ); > > my $add_button = $mw->Button( > -command => \&new_object, > -text => "Create an object." > ); new_object() doesn't have an explicit return value (commented on below). I'd recommend having a look at the documentation for Button and seeing what it requires. Having an explicit return value won't change the code here though. > $exit_button->pack( -side => 'bottom' ); > $add_button->pack(); > MainLoop; > > ################################## > > sub new_object { > my $object = My::Class->new(); # Create a new object to monitor > my $tl = $mw->Toplevel; # Create a top-level window. > $tl->title( $object->{'name'} ); # Set the title of the new window > > # Add Labels to window > $tl->Label( -text => "Name:" )->grid( -row => 0, -column => 0 ); > $tl->Label( -textvariable => \$object->{'name'} )->grid( > -row => 0, > -column => 1 > ); > $tl->Label( -text => "IP Address" )->grid( -row => 1, -column => 0 ); > $tl->Label( -textvariable => \$object->{'ip'} )->grid( > -row => 1, > -column => 1 > ); > $tl->Label( -text => "Uptime:" )->grid( -row => 2, -column => 0 ); > $tl->Label( -textvariable => \$object->{'uptime'} )->grid( > -row => 2, > -column => 1 > ); > > # Create an exit button > $tl->Button( > -text => "Exit", > -command => sub { $tl->destroy() } > )->grid( -row => 20, -column => 0 ); > > # Update the status every 5 seconds. > $tl->repeat( 5000, sub { $object->update_status() } ); > > } This subroutine doesn't appear to return anything. Which of course means it returns whatever the return status of : $tl->repeat( 5000, sub { $object->update_status() } ); is. I'd suggest explicitly returning nothing: return; or explicitly returning that return status: return $tl->repeat( 5000, sub { $object->update_status() } ); so that your future maintainer knows what's supposed to happen. I don't really know what's causing your issue regarding $object not being cleaned up, but I suspect it's something to do with the answer Toby's just given. :) All the best, J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From matt at zensunni.org Mon Jan 12 18:51:47 2009 From: matt at zensunni.org (Matthew Robinson) Date: Tue, 13 Jan 2009 11:51:47 +0900 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects In-Reply-To: <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> Message-ID: <496C01C3.3070500@zensunni.org> Hi Leigh, Leigh Sharpe wrote: > > Here's the bit I couldn't quite understand. My::Class::DESTROY() is not > called when the 'Exit' button on $tl is clicked. If I click on 'Create > an object' several times, and close any or all of the windows it > creates, there is no message printed when the window is closed. Only > when I click on 'Exit' in the main window, thereby terminating the whole > program, do I ever see DESTROY() called. And then it's once for every > object created while the program was running, irrespective of whether > it's window has been closed or not. Try it, the above example is > complete. > > I have tried your example on both OSX and Windows and it is giving me the required behaviour. When I click the Exit button on the child windows I get a message on the console saying 'fred is being destroyed'. The message isn't always immediate but it does appear as a result of clicking the Exit button on the $tl windows. I was using perl 5.8.8 and Tk 804.028 on the Mac and perl 5.10.0 and Tk 804.028 on Windows. HTH, Matt From pjf at perltraining.com.au Mon Jan 12 19:11:40 2009 From: pjf at perltraining.com.au (Paul Fenwick) Date: Tue, 13 Jan 2009 14:11:40 +1100 Subject: [Melbourne-pm] MEETING ANNOUNCEMENT: Tomorrow (Wednesday) 14th January Message-ID: <496C066C.8030001@perltraining.com.au> G'day Everyone, Just a reminder that the next Melbourne.pm meeting is happening tomorrow (Wednesday) night! I look forward to seeing you there! When: Wednesday, 14th January, 6:30pm Where: Remasys Pty Ltd Level 1 180 Flinders St MELBOURNE VIC 3121 Talk: Awesome things you've missed in Perl! (Paul Fenwick) Abstract: Awesome things have been happening in Perl recently; so many that even if you've been paying close attention, you may have missed a few. In this talk we'll examine some of the coolest recent technologies for Perl programmers, including: * Overhauling Perl's Object Oriented framework with Moose. * Making everything a first-class object with autobox. * Slashing your error handling code with autodie. * Building fast, readable and reusable regular expressions with Perl 5.10. * Bundling and building stand-alone applications using PAR, the Perl Archiver. * Astonishingly good profiling with Devel::NYTProf. * Playing MineSweeper automatically with App::SweeperBot. Knowledge of Perl is nice, but not essential to appreciate the contents of this talk. -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From lsharpe at pacificwireless.com.au Mon Jan 12 19:22:35 2009 From: lsharpe at pacificwireless.com.au (Leigh Sharpe) Date: Tue, 13 Jan 2009 14:22:35 +1100 Subject: [Melbourne-pm] TK repeats, scoping and keeping track of objects References: <96CF49BD8B56384395D698BA99007FA347A288@exchange.pacwire.local> <496BED0A.5050007@perltraining.com.au> <96CF49BD8B56384395D698BA99007FA347A289@exchange.pacwire.local> <496C01C3.3070500@zensunni.org> Message-ID: <96CF49BD8B56384395D698BA99007FA347A28A@exchange.pacwire.local> And herein lies the answers: >I was using perl 5.8.8 and Tk 804.028 on the Mac and perl 5.10.0 and Tk 804.028 on Windows. v5.8.8 on Debian works exactly as I would expect. 5.6.1 on windows gives me grief. Looks like it's time for an upgrade. >but I suspect it's something to do with the answer Toby's just given. :) Yes, looks that way. I'll be looking at onDestroy() as well. Thanks to all who chimed in. Leigh -----Original Message----- From: Matthew Robinson [mailto:matt at zensunni.org] Sent: Tuesday, 13 January 2009 1:52 PM To: Leigh Sharpe Cc: Jacinta Richardson; melbourne-pm at pm.org Subject: Re: [Melbourne-pm] TK repeats, scoping and keeping track of objects Hi Leigh, Leigh Sharpe wrote: > > Here's the bit I couldn't quite understand. My::Class::DESTROY() is > not called when the 'Exit' button on $tl is clicked. If I click on > 'Create an object' several times, and close any or all of the windows > it creates, there is no message printed when the window is closed. > Only when I click on 'Exit' in the main window, thereby terminating > the whole program, do I ever see DESTROY() called. And then it's once > for every object created while the program was running, irrespective > of whether it's window has been closed or not. Try it, the above > example is complete. > > I have tried your example on both OSX and Windows and it is giving me the required behaviour. When I click the Exit button on the child windows I get a message on the console saying 'fred is being destroyed'. The message isn't always immediate but it does appear as a result of clicking the Exit button on the $tl windows. I was using perl 5.8.8 and Tk 804.028 on the Mac and perl 5.10.0 and Tk 804.028 on Windows. HTH, Matt From andrew.stuart at flatraterecruitment.com.au Mon Jan 12 20:21:15 2009 From: andrew.stuart at flatraterecruitment.com.au (Andrew Stuart) Date: Tue, 13 Jan 2009 15:21:15 +1100 Subject: [Melbourne-pm] Melbourne job: Perl developer - junior to mid-level References: Message-ID: Melbourne job: Perl developer - junior to mid-level Home ADSL 2+ included (if available in your area). This South Melbourne based company is highly successful and continuing to grow. We're looking for a passionate Perl developer to join the team. The company runs a global network of Linux servers handling RFC822 message processing. We're looking for a passionate and talented Perl programmer to join us - this is a great environment to work in with a hardworking and also fun atmosphere. Your choice of development environment - we'll provide you with a computer to work with operating systems made by Steve, Bill or Linus - it's up to you. The key requirement is experience and an interest in Perl programming. We are happy to consider people with junior to mid- level experience. Skills Required ** OO coding skills ** Enjoys Perl coding ** Passionate about development ** SQL coding skills ** You'll be taught everything else you need to know We're looking for someone who: ** Is passionate about coding ** Gets along well with others in a team ** Is not dogmatic and does not get upset when technical decisions don't go their way ** Flexible and adaptable ? willing to do what needs to be done You'll need to be friendly and a nice person to have around. Apply now! To apply, send your resume to info at flatraterecruitment.com.au Enquiries to (03) 9696 1616 www.flatraterecruitment.com.au -------------- next part -------------- An HTML attachment was scrubbed... URL: From eddy.tan at salmat.com.au Mon Jan 12 21:55:57 2009 From: eddy.tan at salmat.com.au (eddy.tan at salmat.com.au) Date: Tue, 13 Jan 2009 16:55:57 +1100 Subject: [Melbourne-pm] MEETING ANNOUNCEMENT: Tomorrow (Wednesday) 14th January Message-ID: Hi all, melbourne-pm-request at pm.org on Tuesday, 13 January 2009 3:22 PM wrote: > Just a reminder that the next Melbourne.pm meeting is happening > tomorrow (Wednesday) night! I look forward to seeing you there! > > When: Wednesday, 14th January, 6:30pm > Where:Remasys Pty Ltd > Level 1 > 180 Flinders St > MELBOURNE VIC 3121 [snip] I'm planning to come tomorrow (my first time :) ) But might not be able to stay long for a drink - that would be a disadvantage to me as I heard the mongers always head to a cool pub after meeting :( Anyway, is anyone aware of a car park around Remasys? Ta, Eddy *********************************************************************************** This e-mail, including any attachments to it, may contain confidential and/or personal information. If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or take any action based on the information contained within it. Please notify the sender immediately by return e-mail of the error and then delete the original e-mail. The information contained within this e-mail may be solely the opinion of the sender and may not necessarily reflect the position, beliefs or opinions of the organisation on any issue. This email has been swept for the presence of computer viruses known to the organisation?s anti-virus systems. *********************************************************************************** From ddick at aapt.net.au Tue Jan 13 01:05:39 2009 From: ddick at aapt.net.au (David Dick) Date: Tue, 13 Jan 2009 20:05:39 +1100 Subject: [Melbourne-pm] MEETING ANNOUNCEMENT: Tomorrow (Wednesday) 14th January In-Reply-To: References: Message-ID: <496C5963.1040804@aapt.net.au> eddy.tan at salmat.com.au wrote: > Hi all, > > melbourne-pm-request at pm.org on Tuesday, 13 January 2009 3:22 PM wrote: > >> Just a reminder that the next Melbourne.pm meeting is happening >> tomorrow (Wednesday) night! I look forward to seeing you there! >> >> When: Wednesday, 14th January, 6:30pm >> Where:Remasys Pty Ltd >> Level 1 >> 180 Flinders St >> MELBOURNE VIC 3121 >> > > [snip] > > I'm planning to come tomorrow (my first time :) ) > But might not be able to stay long for a drink - that would be a disadvantage to me as I heard the mongers always head to a cool pub after meeting :( > > Anyway, is anyone aware of a car park around Remasys? > Yeah, there's one right next to us. Sorry, i've got no idea about pricing/rates. From alec.clews at gmail.com Wed Jan 14 13:22:56 2009 From: alec.clews at gmail.com (Alec Clews) Date: Thu, 15 Jan 2009 08:22:56 +1100 Subject: [Melbourne-pm] Perl 6 news from Jesse Message-ID: <496E57B0.6040705@gmail.com> "I just retired as Perl 6 Project Manager. Blog post to follow in the next few days" http://twitter.com/obra/statuses/1119278731 -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C Blog http://alecthegeek.wordpress.com/ From jarich at perltraining.com.au Wed Jan 14 17:51:27 2009 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Thu, 15 Jan 2009 12:51:27 +1100 (EST) Subject: [Melbourne-pm] Bids open to run OSDC 2009 Message-ID: <20090115015128.5829EA88B9@teddybear.perltraining.com.au> The Open Source Developers' Conference has been run successfully for the last 5 years, drawing bigger crowds every year. For the first three of those years (2004-2006) it ran in Melbourne before moving to Brisbane (2007) and Sydney (2008). Each year it has had at least three full streams of content running concurrently, catered tea breaks and lunches, a formal sit-down conference dinner on the first night, and free speaker entry. Some years have also included one or two days of tutorial content. The Open Source Developers' Conference provides an important opportunity for developers of open source applications and developers who use open source tools to share knowledge and teach each other about the changes and new ideas that have come up in the last year or so. Our core focus is on writing code, and the tools that make that easier. The Open Source Developers' Club exec are seeking applications from interested parties to host the 2009 Open Source Developers' Conference. Location is not an issue, so long as you are in the oceanic region. If you are interested, or know someone that is, please complete the application form at http://tinyurl.com/osdc2009-application before 1st March 2009. The submission email address is included at the top of the form. We do have some model rules ( http://www.osdcon.org/wiki/Model_Rules ) and a lot of ideas to share. Having said that, we're willing to be as active or quiet as you need us to be. Traditionally the conference has been run in either the last week of November or the first week in December, if you want to deviate a lot from these dates you will need to talk to us first. You will need at group of 6-8 dedicated people who are able to give up an average of 3 hours a week from the acceptance date through to the conference itself. You will be responsible for: - finding and booking the venue(s) - managing your finances (there will be some seed capital) - advertising your call for papers to as many open source programming groups you know (we're happy to share our list with you too) - creating the program (preferably ensuring that no one language or concept unduly dominates) - identifying, deciding upon and inviting keynote speakers - organising all the social events - organising the catering - seeking and arranging sponsorships - advertising the conference - finding volunteers and running an awesome conference In return you will get: - help from us when asked - the satisfaction of arranging an awesome conference - fame for running the best OSDC yet - a chance to improve your profile in the open source world - kudos from the exec committee, speakers and attendees As this is such a big undertaking, we want you to know that we'll support you every step of the way. Should you need more help, we're here to offer advice or step in and do things if we can. Although OSDC Inc isn't flush with cash, there are funds to cover deposits before the money comes in. If for unforeseen difficulties the conference makes a loss, you won't be out of pocket; although we do ask that you keep us apprised of the financial situation on a regular basis and warn us if there may be a problem. We look forward to seeing your application! The Open Source Developers' Club Exec From jarich at perltraining.com.au Thu Jan 15 17:56:28 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Fri, 16 Jan 2009 12:56:28 +1100 Subject: [Melbourne-pm] January talk summary Message-ID: <496FE94C.1050607@perltraining.com.au> G'day folk, Our last meeting was extremely well attended with 25 attendees plus a small child. Paul gave the beta version of his LCA talk for next week and covered: * Moose * PAR * Devel::NYTProf * App::SweeperBot * Perl 5.10's named regular expression captures * Perl 5.10's regular expressions declarations/grammars and touched on autobox. J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From alec.clews at gmail.com Wed Jan 21 16:16:16 2009 From: alec.clews at gmail.com (Alec Clews) Date: Thu, 22 Jan 2009 11:16:16 +1100 Subject: [Melbourne-pm] Runner framework Message-ID: <4977BAD0.3040109@gmail.com> G'Day, I'm looking for a framework that allows me to: * Create different types of runners (e.g. run SQL, run Perl, run other programs) * Handle the tedious bits of logging, running things in order etc etc Does anyone have any suggestions for a suitable module? Thanks -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C Blog http://alecthegeek.wordpress.com/ From mathew.robertson at netratings.com.au Wed Jan 21 17:12:09 2009 From: mathew.robertson at netratings.com.au (Mathew Robertson) Date: Thu, 22 Jan 2009 12:12:09 +1100 Subject: [Melbourne-pm] Runner framework In-Reply-To: <4977BAD0.3040109@gmail.com> References: <4977BAD0.3040109@gmail.com> Message-ID: <4977C7E9.9020708@netratings.com.au> may this: http://search.cpan.org/~jonasbn/Workflow-0.31/lib/Workflow.pm Alec Clews wrote: > G'Day, > > I'm looking for a framework that allows me to: > > * Create different types of runners (e.g. run SQL, run Perl, run other > programs) > * Handle the tedious bits of logging, running things in order etc etc > > Does anyone have any suggestions for a suitable module? > > Thanks > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.clews at gmail.com Wed Jan 21 18:47:31 2009 From: alec.clews at gmail.com (Alec Clews) Date: Thu, 22 Jan 2009 13:47:31 +1100 Subject: [Melbourne-pm] Runner framework In-Reply-To: <4977BAD0.3040109@gmail.com> References: <4977BAD0.3040109@gmail.com> Message-ID: <3c2b63c00901211847y37dc775cy13dba1411b4564d9@mail.gmail.com> Some people are a little confused by my very brief post so here is the more detailed 'use case' On Thu, Jan 22, 2009 at 11:16 AM, Alec Clews wrote: > > I'm looking for a framework that allows me to: > > * Create different types of runners (e.g. run SQL, run Perl, run other > programs) > * Handle the tedious bits of logging, running things in order etc etc I need to run a set of 'scripts' on various application directories. These scripts can be anything. SQL DDL, XML configuration files to be run via a custom program(s), templates to be updated etc... Some scripts will have pre-requisite scripts I need to produce customised logging and error reporting. In most cases some attempt should be made at error recovery or roll-back, but it varies. I'd like a to be able to provide a bunch of files containing these scripts and some meta-data and have a framework do the heavy lifting. > Does anyone have any suggestions for a suitable module? Make sense? Cheers -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C blog:http://alecthegeek.wordpress.com/ From mathew.robertson at netratings.com.au Thu Jan 22 17:28:56 2009 From: mathew.robertson at netratings.com.au (Mathew Robertson) Date: Fri, 23 Jan 2009 12:28:56 +1100 Subject: [Melbourne-pm] Runner framework In-Reply-To: <3c2b63c00901211847y37dc775cy13dba1411b4564d9@mail.gmail.com> References: <4977BAD0.3040109@gmail.com> <3c2b63c00901211847y37dc775cy13dba1411b4564d9@mail.gmail.com> Message-ID: <49791D58.80006@netratings.com.au> > I need to run a set of 'scripts' on various application directories. > These scripts can be anything. SQL DDL, XML configuration files to be > run via a custom program(s), templates to be updated etc... > > Some scripts will have pre-requisite scripts > > I need to produce customised logging and error reporting. In most > cases some attempt should be made at error recovery or roll-back, but > it varies. > > I'd like a to be able to provide a bunch of files containing these > scripts and some meta-data and have a framework do the heavy lifting I'll venture out to say "yes and no" - basically what you just described was shell-programming. ie: you want to call specific commands on user-specified directories, but with generic tools for execution, logging, rollback... cheers, Mathew From wayland at wayland.id.au Thu Jan 22 19:11:56 2009 From: wayland at wayland.id.au (Timothy S. Nelson) Date: Fri, 23 Jan 2009 14:11:56 +1100 (EST) Subject: [Melbourne-pm] Runner framework In-Reply-To: <49791D58.80006@netratings.com.au> References: <4977BAD0.3040109@gmail.com> <3c2b63c00901211847y37dc775cy13dba1411b4564d9@mail.gmail.com> <49791D58.80006@netratings.com.au> Message-ID: On Fri, 23 Jan 2009, Mathew Robertson wrote: >> I need to run a set of 'scripts' on various application directories. >> These scripts can be anything. SQL DDL, XML configuration files to be >> run via a custom program(s), templates to be updated etc... >> >> Some scripts will have pre-requisite scripts >> >> I need to produce customised logging and error reporting. In most >> cases some attempt should be made at error recovery or roll-back, but >> it varies. >> >> I'd like a to be able to provide a bunch of files containing these >> scripts and some meta-data and have a framework do the heavy lifting > I'll venture out to say "yes and no" - basically what you just described was > shell-programming. This was exactly the thought that prompted me to ask him to clarify. Question for Alec; what platform are you on? Because us Unix types take the "bash" shell for granted, which is better than the Windows command/cmd shell. But on the other hand, Perl is more flexible than bash :). I'd like to point out that none of the lifting here sounds particularly heavy, if you're familiar with the appropriate parts of perl. Have you looked at open3 (aka IPC::open3), opendir, and the like? use File::Basename; use IPC::open3; $path = "/path/to/scriptdir"; @suffixes = qw(sql pl); opendir(DIR, $path); foreach(grep { !/^\./ and -f } readdir(DIR)) { ($count) = split(/-/, $_, 2); ($name, $path, $suffix) = fileparse($_, @suffixes); push @{ $scripts{$count} }, { count => $count, filename => $_, type => $suffix, }; } closedir(DIR); foreach $count (sort { $a <=> $b } keys %scripts) { foreach $filehash ($scripts{$count}) { ($filename, $type) = map { $filehash->{$_} } qw(filename type); $text = join '', getfile($filename); &$type($text, $filename); } } exit; sub sql { my($text) = @_; my($wtr, $rdr, $err, $pid); $pid = open3($wtr, $rdr, $err, 'mysql -u username'); print $wtr $text; # read from $rdr here } sub getfile { my($filename) = @_; my(@lines); open(FILE, $filename) or die "Error opening file '$filename': $!"; @lines = ; close(FILE) or die "Error closing file '$filename': $!"; return(@lines); } Anyway, I haven't tested this or anything, but it should give you something to go on. You'll presumably need to read the IPC::open3 man page fairly carefully. The assumption in the script is that all your test files have names like 01-foo.sql and things like that. The call to &$type($text, $filename) will (if the $type variable contains 'sql') call the sql() function. You could choose a different method of file type identification. If you use Unix, my file type identification would probably do something like: sub get_type { my($filename) = @_; my(@lines); local($_); @lines = getfile("file $filename |"); # Note that the thing with the | # on the end gets passed to the "open" function, which runs it # as a command @lines > 1 and die "What's going on?\n"; @lines < 1 and die "Unknown type for file '$filename'\n"; $_ = $lines[0]; /SQL/ and return('sql'); chomp; die "Found type '$lines[0]', but we don't recognise it"; } That's a more reliable ID method, but unfortunately, doesn't work on Windows. Hope all this helps. :) --------------------------------------------------------------------- | Name: Tim Nelson | Because the Creator is, | | E-mail: wayland at wayland.id.au | I am | --------------------------------------------------------------------- ----BEGIN GEEK CODE BLOCK---- Version 3.12 GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y- -----END GEEK CODE BLOCK----- From thogard at abnormal.com Mon Jan 26 03:54:10 2009 From: thogard at abnormal.com (Tim Hogard) Date: Mon, 26 Jan 2009 11:54:10 +0000 (UTC) Subject: [Melbourne-pm] 3 dimensional array inner loop sizes Message-ID: <200901261154.n0QBsAX0042536@v.abnormal.com> Greetings everyone, I have a bit of a problem I can't work out. I have a process that goes through a bunch of text files and counts up a bunch of stats and sticks them in a 3 dimensional array: $data[$category][$row][$col]++; Now latter I want to print out the counts like: Cat 1 1 2 3 1 2 3 2 9 1 Cat 2 2 3 1 3 1 2 3 4 The outer loop is easy: foreach $category ( 1 .. $#data ) { Yet I don't wnat to do this: foreach $row ( 1 .. $max_row ) { foreach $col ( 1 .. $max_col ) { print $data[$category][$row][$col]++; What is the proper syntax to find out $max_row for $data[category] and how do I find out $max_col for $data[category][$max_row]? I tried things like $#data[$category] but that doesn't work. I'm using perl 5.8.8 and 5.10. Thanks, -tim From swatkins at fastmail.fm Mon Jan 26 12:27:40 2009 From: swatkins at fastmail.fm (Sam Watkins) Date: Tue, 27 Jan 2009 04:27:40 +0800 Subject: [Melbourne-pm] 3 dimensional array inner loop sizes In-Reply-To: <200901261154.n0QBsAX0042536@v.abnormal.com> References: <200901261154.n0QBsAX0042536@v.abnormal.com> Message-ID: <1233001660.28456.1296848659@webmail.messagingengine.com> hi Tim, $ perl -e '$data[0][0][15]++; print $#{$data[0][0]}' 15 hope that helps! Sam On Mon, 26 Jan 2009 11:54 +0000, "Tim Hogard" wrote: > I have a bit of a problem I can't work out. > > I have a process that goes through a bunch of text files and counts up > a bunch of stats and sticks them in a 3 dimensional array: > > $data[$category][$row][$col]++; > ... > What is the proper syntax to find out $max_row for $data[category] > and how do I find out $max_col for $data[category][$max_row]? > I tried things like $#data[$category] but that doesn't work. > > I'm using perl 5.8.8 and 5.10. > > Thanks, > > -tim From simon at unisolve.com.au Mon Jan 26 12:39:43 2009 From: simon at unisolve.com.au (Simon Taylor) Date: Tue, 27 Jan 2009 07:39:43 +1100 Subject: [Melbourne-pm] 3 dimensional array inner loop sizes In-Reply-To: <200901261154.n0QBsAX0042536@v.abnormal.com> References: <200901261154.n0QBsAX0042536@v.abnormal.com> Message-ID: <497E1F8F.8060303@unisolve.com.au> Tim Hogard wrote: > Greetings everyone, > > I have a bit of a problem I can't work out. > > I have a process that goes through a bunch of text files and counts up > a bunch of stats and sticks them in a 3 dimensional array: > > $data[$category][$row][$col]++; > > Now latter I want to print out the counts like: > Cat 1 > 1 2 3 > 1 2 3 > 2 9 1 > Cat 2 > 2 3 1 3 > 1 2 3 4 > > The outer loop is easy: > foreach $category ( 1 .. $#data ) { > Yet I don't wnat to do this: > foreach $row ( 1 .. $max_row ) { > foreach $col ( 1 .. $max_col ) { > print $data[$category][$row][$col]++; > > What is the proper syntax to find out $max_row for $data[category] > and how do I find out $max_col for $data[category][$max_row]? > I tried things like $#data[$category] but that doesn't work. > > I'm using perl 5.8.8 and 5.10. > > See the section "ARRAY OF ARRAYS" in perldoc perldsc. Cheers, Simon From jarich at perltraining.com.au Fri Jan 30 06:17:53 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Sat, 31 Jan 2009 01:17:53 +1100 Subject: [Melbourne-pm] Job: Linux sysadmin with Perl experience Message-ID: <49830C11.7090400@perltraining.com.au> G'day all, A friend of mine works for Toggletext (which does language research and automated translation tools - like kataku). She's asked me to pass on this job ad. -------------------------------------- Linux Systems Administrator ToggleText is looking for a Linux systems admininistrator with good communication skills, keen curiosity and the ability to learn on the job. 1-2 years experience OR completion/near-completion of an appropriate degree/diploma is required (i.e. may be appropriate for a graduate). ToggleText is a friendly small business with flexible working hours. Pay is negotiable on experience. For the right candidate we can make this position full time (40 hours/week) or part time (minimum 20 hours/week) as you prefer. Start date is ASAP. If you like the idea of running the show and getting your teeth into a bit of everything, this may be the right job for you. Essential qualities * Linux systems administration familiarity (pref. RHEL/CentOS and Xen virtualisation software) * Apache web server familiarity * Perl experience * Knowledge of LANs and DNS * Email administration experience (preferably sendmail) * Exposure to version control management systems * Conscientious documentor! Desirable qualities * Windows system administration * Prolog exposure/experience * DBMS experience (preferably PostgreSQL) * Interest/experience in natural language processing/computational linguistics * Experience in Indonesia or the Philippines (languages or business) * C#/.NET familiarity About ToggleText ToggleText is a privately owned company developing language technology software in Sandringham, Victoria. Our office is metres from both Sandringham train station and Sandringham beach. http://www.toggletext.com/ Apply by email to resumes at toggletext dot com. Applications close Friday 13th February 2009. If you have any questions, please contact Ben MacLeod on 03 9521 8011. -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au |