From sgc294 at internode.on.net Thu Sep 2 23:18:54 2010 From: sgc294 at internode.on.net (Andrew Dent) Date: Fri, 03 Sep 2010 16:18:54 +1000 Subject: [Melbourne-pm] Editor mod in Padre and Notepad++ for Regexp::Grammers magic variable Message-ID: <4C80934E.4080604@internode.on.net> G'day all I've started writing some code using the Regexp::Grammers module and I have a niggly problem with how Padre and Notepad++ perfrom syntax highlighting when the %/ is used. If I am only using $/ then everything is fine, but %/ doesn't work the same. They both see the / as the beginning of a regex and change the color of the code that follows. Example code: foreach my $key (keys %/) { print "$key\n"; } and the editor believe that ') { print "$key\n";}' is in a regex. But if instead I have foreach my $key (keys %slash) { print "$key\n"; } the syntax highlighting works correctly. Does anyone know how I can modify the settings for syntax hightlighting in either or both Notepad++ and Padre when a / is used after a %? Cheers Andrew Dent From sam at nipl.net Thu Sep 2 23:30:46 2010 From: sam at nipl.net (Sam Watkins) Date: Fri, 3 Sep 2010 06:30:46 +0000 Subject: [Melbourne-pm] Editor mod in Padre and Notepad++ for Regexp::Grammers magic variable In-Reply-To: <4C80934E.4080604@internode.on.net> References: <4C80934E.4080604@internode.on.net> Message-ID: <20100903063046.GA8190@nipl.net> On Fri, Sep 03, 2010 at 04:18:54PM +1000, Andrew Dent wrote: > I've started writing some code using the Regexp::Grammers module and I > have a niggly problem with how Padre and Notepad++ perfrom syntax > highlighting when the %/ is used. Is that %/ a special variable to perl? I don't see it's definition in 'man perlvar'. Sam From sam at nipl.net Thu Sep 2 23:31:49 2010 From: sam at nipl.net (Sam Watkins) Date: Fri, 3 Sep 2010 06:31:49 +0000 Subject: [Melbourne-pm] Editor mod in Padre and Notepad++ for Regexp::Grammers magic variable In-Reply-To: <20100903063046.GA8190@nipl.net> References: <4C80934E.4080604@internode.on.net> <20100903063046.GA8190@nipl.net> Message-ID: <20100903063149.GB8190@nipl.net> sorry, please excuse my stupid question, you did explain that %/ is a magic variable for Regexp::Grammers. From sgc294 at internode.on.net Thu Sep 2 23:38:42 2010 From: sgc294 at internode.on.net (Andrew Dent) Date: Fri, 03 Sep 2010 16:38:42 +1000 Subject: [Melbourne-pm] Editor mod in Padre and Notepad++ for Regexp::Grammars magic variable In-Reply-To: <20100903063149.GB8190@nipl.net> References: <4C80934E.4080604@internode.on.net> <20100903063046.GA8190@nipl.net> <20100903063149.GB8190@nipl.net> Message-ID: <4C8097F2.9010503@internode.on.net> I made a mistake as well. It is Grammars, not Grammers. I've fixed the subject line. On 9/3/2010 4:31 PM, Sam Watkins wrote: > sorry, please excuse my stupid question, you did explain that %/ is a magic > variable for Regexp::Grammers. > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > From sgc294 at internode.on.net Sat Sep 4 04:30:40 2010 From: sgc294 at internode.on.net (Andrew) Date: Sat, 04 Sep 2010 21:30:40 +1000 Subject: [Melbourne-pm] Editor mod in Padre and Notepad++ for Regexp::Grammars magic variable In-Reply-To: <4C80934E.4080604@internode.on.net> References: <4C80934E.4080604@internode.on.net> Message-ID: <4C822DE0.7020908@internode.on.net> After Sam mentioning that vim handled %/ better than the other two, I've have a solution to my problem. However, out of the box, vim doesn't treat %/ as a variable. But it doesn't treat it as the beginning of a regex either, so it is closer than Padre or Notepad++. But Sam's pointer to vim was great as it seems the learning curve for customizing the syntax highlighting in vim is not nearly as steep (for me at least) as I found Padre and Notepad++ to be. To make vim treat %/ as a variable (tested on Ubuntu) 1. Create the directory ~/.vim/after/syntax 2. In that directory create a file called perl.vim 3. Put this line in the file syn match perlVarSlash "%/" And bingo. Vim will consider %/ to be a variable, like it does for $/ Many thanks to Sam for suggesting to use vim instead. Cheers Andrew Dent From jarich at perltraining.com.au Sun Sep 5 21:11:16 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 06 Sep 2010 14:11:16 +1000 Subject: [Melbourne-pm] Contract work: Documenting Perl Code Message-ID: <4C8469E4.9060001@perltraining.com.au> G'day folk, One of our past clients has asked if we can recommend anyone for the following work. We didn't write the code they want documented, and I suspect it's probably a mix of the most "interesting" aspects of Perl 4 and Perl 5, mixed together. If you are interested, please reply to Paul and I (contact at perltraining.com.au) and we can introduce you. I'm already going to mention that without seeing the code, agreeing with the anticipated time-frames is going to be a challenge. Thanks in advance, Jacinta ======================= Statement of work ============================ We are looking for a programmer with good documentation skills or someone who is good at documentation with Perl skills who can help us document the Perl code used by our [shopping cart] solution. We have only one programmer working on and being completely familiar with the project, so need to get some documentation happening for ourselves but also because of a project we are trying to secure, which requires appropriate documentation of the system. Any suggestions will be greatly appreciated. Below is a general overview of what we believe the task to entail. The programmer will help, of course, but his English skills are not the best unfortunately. Overview (Time estimation : 1 week) A high level view of the project, focusing on - An architectural overview of the GlobeCharge solution - A schematic diagram of the major scripts and database elements in the project - The location of the various elements within CVS. - Functional description of the various scripts - An overview of the folder structure of the GlobeCharge server - A list of all of the requirements for this program, including platforms, Perl version requirements, Perl modules included, other modules included, database requirements, memory and any other system requirements with a view to provide a outline of how an installation of this program on another system may take place Templating (Time estimation : 2 days) - An outline of the Templating system as it is used in [the shopping cart], including the commands used by the Templating system, and the required location for the various elements as used by the system. - Documentation listing the use of the inline tags used by the Templating system and the formatting required for these tags. - Documentation explaining the use of the language Database (Time estimation : 2 days) - A list of the databases, tables and elements used, showing the relationships used and outlining the use for each elements. The tables used form a simple relationship database schema. - A view of the database queries performed by [the shopping cart] with a view to improving either the queries or the table structure at a later date. From toby.corkindale at strategicdata.com.au Tue Sep 7 18:29:14 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 08 Sep 2010 11:29:14 +1000 Subject: [Melbourne-pm] Melbourne Perl Mongers meeting TONIGHT! Message-ID: <4C86E6EA.1020708@strategicdata.com.au> Good morning, The September Melbourne Perl Mongers meeting will be held TONIGHT. It will be hosted by David Dick at Remasys from 6:30pm. Remasys Pty Ltd Level 1 180 Flinders St MELBOURNE VIC 3121 I still don't think we have any talks though. I'll give a lightning talk on what's new in DBD::SQLite 1.30 and why it's important. Are there some other interesting little tools or programming tricks that YOU have seen lately that you'd care to demonstrate? Thanks, Toby From pjf at perltraining.com.au Tue Sep 7 18:45:35 2010 From: pjf at perltraining.com.au (Paul Fenwick) Date: Wed, 08 Sep 2010 11:45:35 +1000 Subject: [Melbourne-pm] Melbourne Perl Mongers meeting TONIGHT! In-Reply-To: <4C86E6EA.1020708@strategicdata.com.au> References: <4C86E6EA.1020708@strategicdata.com.au> Message-ID: <4C86EABF.2040607@perltraining.com.au> G'day MPM/Toby, Toby Corkindale wrote: > The September Melbourne Perl Mongers meeting will be held TONIGHT. Toby, you totally, utterly rock. Thank you! > Are there some other interesting little tools or programming tricks that > YOU have seen lately that you'd care to demonstrate? I'm laptopless today in celebration of father's day[1], which makes giving a talk hard. However I am back in Melbourne after ten weeks in the USA, will definitely be at Melbourne.pm, and have plenty of stories to tell at the social afterwards for anyone foolish to listen to them. :) Looking forward to seeing you all tonight! Paul [1] My family has strange traditions. As far as I can tell, we've gone laptop-free on father's day[2] for generations, at least as far back as the 1800s in England. [2] We celebrate Zen Russian Orthodox father's day, which is today. -- Paul Fenwick | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 From toby.corkindale at strategicdata.com.au Tue Sep 7 19:09:15 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 08 Sep 2010 12:09:15 +1000 Subject: [Melbourne-pm] Melbourne Perl Mongers meeting TONIGHT! In-Reply-To: <4C86E6EA.1020708@strategicdata.com.au> References: <4C86E6EA.1020708@strategicdata.com.au> Message-ID: <4C86F04B.3050509@strategicdata.com.au> On 08/09/10 11:29, Toby Corkindale wrote: > I'll give a lightning talk on what's new in DBD::SQLite 1.30 and why > it's important. > > Are there some other interesting little tools or programming tricks that > YOU have seen lately that you'd care to demonstrate? I've been thinking of doing a short talk on HTML::FormHandler and why it rocks; if I manage to find some time today I'll present that tonight too. Cheers, Toby From toby.corkindale at strategicdata.com.au Wed Sep 8 00:43:48 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 08 Sep 2010 17:43:48 +1000 Subject: [Melbourne-pm] Melbourne Perl Mongers meeting TONIGHT! In-Reply-To: <4C86F04B.3050509@strategicdata.com.au> References: <4C86E6EA.1020708@strategicdata.com.au> <4C86F04B.3050509@strategicdata.com.au> Message-ID: <4C873EB4.4040007@strategicdata.com.au> On 08/09/10 12:09, Toby Corkindale wrote: > On 08/09/10 11:29, Toby Corkindale wrote: > I've been thinking of doing a short talk on HTML::FormHandler and why it > rocks; if I manage to find some time today I'll present that tonight too. I've written it up, but can someone else provide a laptop or computer at the venue which has a USB slot and Google Chrome installed? cheers, Toby From melbourne-pm at mjch.net Fri Sep 10 15:03:25 2010 From: melbourne-pm at mjch.net (Malcolm Herbert) Date: Sat, 11 Sep 2010 08:03:25 +1000 Subject: [Melbourne-pm] recovering memory used in IO::String or similar In-Reply-To: <1284153798.21540.1394402983@webmail.messagingengine.com> References: <1284153798.21540.1394402983@webmail.messagingengine.com> Message-ID: <1284156205.27554.1394408039@webmail.messagingengine.com> Sent again from the correct address ... On Sat, 11 Sep 2010 07:23 +1000, "Malcolm Herbert" wrote: > I want to be able to use an IO::String file handle interface in order to > interact with one particular class, however I don't want all the data I > shove into the string to remain hanging around but be able to be retired > without closing and re-opening the handle - is there a way to do this? > > I have tried to resize the underlying tied variable with substr and > remove the aging data that way however this seems to remove the > association with the original tied variable ... plus leads to problems if > the class I'm using keeps internal state about the handle ... > > Regards, > Malcolm -- Malcolm Herbert This brain intentionally mjch at mjch.net left blank From mathew.blair.robertson at gmail.com Sat Sep 11 02:23:08 2010 From: mathew.blair.robertson at gmail.com (Mathew Robertson) Date: Sat, 11 Sep 2010 19:23:08 +1000 Subject: [Melbourne-pm] recovering memory used in IO::String or similar In-Reply-To: <1284156205.27554.1394408039@webmail.messagingengine.com> References: <1284153798.21540.1394402983@webmail.messagingengine.com> <1284156205.27554.1394408039@webmail.messagingengine.com> Message-ID: Have you tried 'truncate' (see "perldoc IO::String") cheers, Mathew On 11 September 2010 08:03, Malcolm Herbert wrote: > Sent again from the correct address ... > > On Sat, 11 Sep 2010 07:23 +1000, "Malcolm Herbert" > wrote: >> I want to be able to use an IO::String file handle interface in order to >> interact with one particular class, however I don't want all the data I >> shove into the string to remain hanging around but be able to be retired >> without closing and re-opening the handle - is there a way to do this? >> >> I have tried to resize the underlying tied variable with substr and >> remove the aging data that way however this seems to remove the >> association with the original tied variable ... plus leads to problems if >> the class I'm using keeps internal state about the handle ... >> >> Regards, >> Malcolm > > -- > Malcolm Herbert ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?This brain intentionally > mjch at mjch.net ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?left blank > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > From alfiejohn at gmail.com Sat Sep 11 04:40:15 2010 From: alfiejohn at gmail.com (Alfie John) Date: Sat, 11 Sep 2010 21:40:15 +1000 Subject: [Melbourne-pm] recovering memory used in IO::String or similar In-Reply-To: <1284156205.27554.1394408039@webmail.messagingengine.com> References: <1284153798.21540.1394402983@webmail.messagingengine.com> <1284156205.27554.1394408039@webmail.messagingengine.com> Message-ID: Hey Malcolm, If you're can have your contents in a file, you could get away with what you want by using mmap: $ dd if=/dev/urandom count=1000000 of=/tmp/randfile -- 8< -- #!/usr/bin/perl use strict; use warnings; use IO::String; use File::Map qw{ map_file unmap }; print_size(); map_file my $v, "/tmp/randfile"; print_size(); my $string = IO::String->new( $v ); print_size(); $string->getline(); print_size(); $string->close(); unmap( $v ); print_size(); sub print_size { open my $statm, '< /proc/self/statm' or die $!; my ( $size ) = split /\s/, <$statm>; $size *= 4096; print "size: $size\n"; } -- >8 -- Output on a 512Mb file is: size: 21381120 size: 533381120 size: 533381120 size: 533381120 size: 21381120 If you can't put the contents in a file, you might still be able to get away with using mmap but you'll have to play with Sys::Mmap (don't give new() the OPTIONALFILENAME param). Alfie On Sat, Sep 11, 2010 at 8:03 AM, Malcolm Herbert wrote: > Sent again from the correct address ... > > On Sat, 11 Sep 2010 07:23 +1000, "Malcolm Herbert" > wrote: > > I want to be able to use an IO::String file handle interface in order to > > interact with one particular class, however I don't want all the data I > > shove into the string to remain hanging around but be able to be retired > > without closing and re-opening the handle - is there a way to do this? > > > > I have tried to resize the underlying tied variable with substr and > > remove the aging data that way however this seems to remove the > > association with the original tied variable ... plus leads to problems if > > the class I'm using keeps internal state about the handle ... > > > > Regards, > > Malcolm > > -- > Malcolm Herbert This brain intentionally > mjch at mjch.net left blank > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From melbourne-pm at mjch.net Sat Sep 11 07:36:58 2010 From: melbourne-pm at mjch.net (Malcolm Herbert) Date: Sun, 12 Sep 2010 00:36:58 +1000 Subject: [Melbourne-pm] recovering memory used in IO::String or similar In-Reply-To: References: <1284153798.21540.1394402983@webmail.messagingengine.com><1284156205.27554.1394408039@webmail.messagingengine.com> Message-ID: <1284215818.12683.1394479481@webmail.messagingengine.com> Thanks to Alfie John and Mathew Robertson for their suggestions - On Sat, 11 Sep 2010 21:40 +1000, "Alfie John" wrote: > If you're can have your contents in a file, you could get away with what > you want by using mmap: ooh ... nice, didn't even realise this was possible ... I like this a lot ... :) Unfortunately I'm dealing with a net stream, so I don't have it locally on the filesystem in order to use this, but will definitely keep it in mind for the future ... On Sat, 11 Sep 2010 19:23 +1000, "Mathew Robertson" wrote: > Have you tried 'truncate' (see "perldoc IO::String") I was looking to remove data from behind the file pointer actually, rather than chop off the tail of the file, so truncate() wouldn't help in this instance. I grant you that I wasn't clear about that in the original post ... :) In the end I found that it was a combination of things that was causing the corruption I was seeing in the code. The IO::String problem turned out to be reasonably simple to fix: my $buf = ""; my $io = IO::String->new($buf); then later: if (length($buf) > $MAXBUF) { my $pos = $io->pos; $buf = substr($buf, $MINBUF); $io->pos($pos - $MINBUF); } $buf .= $data; The main drawback from this is that tell(), pos() and seek() will reference their position from the beginning of the string rather than the bytes that have passed through the handle, but that doesn't seem to bother the class that I'm interfacing with ... Regards, Malcolm -- Malcolm Herbert This brain intentionally mjch at mjch.net left blank From jarich at perltraining.com.au Tue Sep 14 20:16:55 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Wed, 15 Sep 2010 13:16:55 +1000 Subject: [Melbourne-pm] New course: Enterprise Perl running October 11th - 15th Message-ID: <4C903AA7.4070005@perltraining.com.au> G'day folk, Enterprise Perl exists to teach people who already know all the Perl basics, the things they might have missed out on learning about if they haven't been paying close attention to all the new shiny things that have arrived in Perl over the last few years. I hope to see a few of you on the course. Perl Mongers get a 5% discount when booking if you ask for it. Questions, and recommendations for technologies we might not have noticed are very much welcome! We're also running our regular Programming Perl course in Melbourne on 8th - 12th November 2010. We're happy to extend our discount for this course too. I can confirm that this could will run. J New course: Enterprise Perl =========================== http://perltraining.com.au/courses/enterprise.html Running in Melbourne 11th - 15th October. Book before 24th September to receive your early bird free book. Course description: ------------------- You already know Perl. You write in Perl regularly, you may have even released some code to the CPAN but are you sure you're doing it right? Languages and techniques evolve over time, and Perl is no exception. This course will cover many of the best modern and practical techniques in Perl, including: * How to gain feedback and enforce coding standards with Perl::Critic. * Starting your project on the right foot, without repeating yourself, using Module::Starter. * Module documentation and POD. * Test-driven development, test coverage, advanced testing. * Fundamentals of old-style object orientation. * Using Moose for flexible object oriented design, including inheritance, roles, types and coercion, and how to integrate with old-style OO. * Error handling code with autodie and Try::Tiny. * Wizardly work with databases, using DBI and DBIx::Class. * Profiling your code with Devel::NYTProf, and examining your test suite coverage with Devel::Cover. * How to bundle your code and dependencies with PAR, the Perl Archiver. Target audience --------------- Perl programmers with a thorough understanding and at least 3 months practice of the material in our Programming Perl course. Enterprise Perl will bring you up to date with modern standards of Perl programming. Group discount ============== Make a single booking for three or more people on the same course and receive a 5% discount per person. Referral bonuses ================ Refer your friends and colleagues to us, and get a free book for each booking mentioning you, made before the early bird date. Books can be selected from our list at: http://perltraining.com.au/books.html From jarich at perltraining.com.au Tue Sep 14 20:43:44 2010 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Wed, 15 Sep 2010 13:43:44 +1000 (EST) Subject: [Melbourne-pm] OSDC 2010 Call for Presentations! Message-ID: <20100915034345.225E111005F@teddybear.perltraining.com.au> Thank you to everyone who has submitted a proposal to OSDC this year. Although we have a number of fantastic proposals available to us, we'd love to have a few more so that we can better balance the program. So I'm opening the CPF for a few more days. It will close properly on Monday 20th September with announcements of accepted talks going out on Monday 27th September. In 2010, the Open Source Developers' Conference (OSDC) is back in Melbourne! Running Wednesday 24th - Friday 26th November 2010, OSDC is a great way to meet your peers, share your knowledge, and improve your skills. Be part of our 7th year of this fantastic conference, run by open source developers for open source developers. Submit a proposal on open source languages, technologies, tools and projects. http://2010.osdc.com.au/call-for-proposals Key dates: Call for Proposals Closes 20th September 2010 Proposal Acceptance 27th September OSDC 2010 Conference 24th to 26th November 2010 Please feel free to pass this on to any other people or groups you think might be interested in submitting a paper! Hope to see you there! OSDC 2010 committee From toby.corkindale at strategicdata.com.au Tue Sep 14 21:47:05 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 15 Sep 2010 14:47:05 +1000 Subject: [Melbourne-pm] OSDC 2010 Call for Presentations! In-Reply-To: <20100915034345.225E111005F@teddybear.perltraining.com.au> References: <20100915034345.225E111005F@teddybear.perltraining.com.au> Message-ID: <4C904FC9.5090501@strategicdata.com.au> On 15/09/10 13:43, jarich at perltraining.com.au wrote: > Thank you to everyone who has submitted a proposal to OSDC this year. > Although we have a number of fantastic proposals available to us, we'd love to > have a few more so that we can better balance the program. So I'm opening the > CPF for a few more days. It will close properly on Monday 20th September with > announcements of accepted talks going out on Monday 27th September. I've done a few little talks over the last year; some lightning, some longer. Do you think any of those would be useful for OSDC, if I fleshed one out into a longer, more in-depth piece? * (some pun on forms and perl) - HTML-FormHandler talk * A comparison of some simple tasks in Perl, Scala and Go. * An beginners guide to Moose. Erm, what else have I rambled on about lately? Is there anything people would like to see that maybe I or we could knock up into a talk in time? The problem is that I don't feel like I'm a good speaker; my talks are just blocks of text with me explaining them, like a lecturer. As an aside, could we convince Damian Conway to do his natural-language-parsing with RecDescent talk at OSDC? It was very impressive, and I'm sure would be, again, a very popular talk. Cheers, Toby From jarich at perltraining.com.au Sun Sep 19 20:23:24 2010 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Mon, 20 Sep 2010 13:23:24 +1000 (EST) Subject: [Melbourne-pm] Last day to propose a talk for OSDC 2010! Message-ID: <20100920032325.35006110060@teddybear.perltraining.com.au> Today is your last chance to submit your proposals to OSDC! Announcements of accepted talks will go out on Monday 27th September. In 2010, the Open Source Developers' Conference (OSDC) is back in Melbourne! Running Wednesday 24th - Friday 26th November 2010, OSDC is a great way to meet your peers, share your knowledge, and improve your skills. Be part of our 7th year of this fantastic conference, run by open source developers for open source developers. Submit a proposal on open source languages, technologies, tools and projects. http://2010.osdc.com.au/call-for-proposals Key dates: Call for Proposals Closes 20th September 2010 Proposal Acceptance 27th September OSDC 2010 Conference 24th to 26th November 2010 Please feel free to pass this on to any other people or groups you think might be interested in submitting a paper! Hope to see you there! OSDC 2010 committee From jarich at perltraining.com.au Sun Sep 19 20:45:10 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 20 Sep 2010 13:45:10 +1000 Subject: [Melbourne-pm] LCA2011 Open Programming Miniconf CFP Message-ID: <4C96D8C6.3060409@perltraining.com.au> ** On behalf of Christopher Neugebauer ** The LCA2011 Open Programming Miniconf helps bridge the gap between the low-level developer and the end-user by bringing the topic of tools and techniques for application development to Linux.conf.au. We invite 25-minute talks on a wide range of topics, tools and languages with the aim of bringing together open source developers with presentations that share techniques, best practices and values amongst users of all open source programming languages. If you know something about a topic of interest to the LCA Developer community, check out our call for presentations at http://blogs.tucs.org.au/opm/cfp/ and submit a proposal! OPM2011 is part of Linux.conf.au 2011, being held at the Queensland University of Technology in Brisbane in January 2011. From jarich at perltraining.com.au Tue Sep 28 07:00:39 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Wed, 29 Sep 2010 00:00:39 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? Message-ID: <4CA1F507.3030505@perltraining.com.au> G'day folk, I have two tables in DBIx::Class and I'm trying to work out how to do an aggregate query across both of them: package Staff::Schema::Result::Staff; use warnings; use strict; use base qw/DBIx::Class::Core/; __PACKAGE__->table('staff'); __PACKAGE__->add_column(staffid => { is_auto_increment => 1},); __PACKAGE__->add_columns(qw(firstname lastname address city state position wage)); __PACKAGE__->set_primary_key('staffid'); __PACKAGE__->has_many(projects => 'Staff::Schema::Result::Project', 'staffid'); 1; package Staff::Schema::Result::Project; use warnings; use strict; use base qw/DBIx::Class::Core/; __PACKAGE__->table('projects'); __PACKAGE__->add_column(staffid => { is_foreign_key => 1 } ); __PACKAGE__->add_columns(qw(projectname allocation)); __PACKAGE__->set_primary_key('staffid', 'projectname'); __PACKAGE__->belongs_to(staff => 'Staff::Schema::Result::Staff', 'staffid'); 1; The SQL I'm trying to generate is this: SELECT s.staffid, count(projectname) as numprojects FROM staff s, projects p WHERE p.staffid = s.staffid GROUP BY s.staffid ORDER BY numprojects DESC I've tried a few things, but I just don't seem to be able to get this one to work. Is it true that I'll have to reach out to the underlying dbi object to do it? If so, how do I do that? # doesn't work, but is where I got up to... my $most_busy = $schema->resultset('Project')->search( { count => { join => 'Staff' } }, { group_by => 'me.staffid' }, { prefetch => 'staff' }, ); # generates "SELECT me.staffid, me.projectname, me.allocation, staff.staffid, staff.firstname, staff.lastname, staff.address, staff.city, staff.state, staff.position, staff.wage FROM projects me JOIN staff staff ON staff.staffid = me.staffid WHERE ( count JOIN ? )" with ParamValues: 0='Staff'] -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From tjc at wintrmute.net Tue Sep 28 07:10:29 2010 From: tjc at wintrmute.net (Toby Wintermute) Date: Wed, 29 Sep 2010 00:10:29 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: <4CA1F507.3030505@perltraining.com.au> References: <4CA1F507.3030505@perltraining.com.au> Message-ID: On 29 September 2010 00:00, Jacinta Richardson wrote: > G'day folk, > > I have two tables in DBIx::Class and I'm trying to work out how to do an > aggregate query across both of them: > > package Staff::Schema::Result::Staff; > use warnings; > use strict; > use base qw/DBIx::Class::Core/; > > __PACKAGE__->table('staff'); > __PACKAGE__->add_column(staffid => { is_auto_increment => 1},); > __PACKAGE__->add_columns(qw(firstname lastname address city > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? state position wage)); > __PACKAGE__->set_primary_key('staffid'); > __PACKAGE__->has_many(projects => 'Staff::Schema::Result::Project', 'staffid'); > 1; > > package Staff::Schema::Result::Project; > > use warnings; > use strict; > use base qw/DBIx::Class::Core/; > > __PACKAGE__->table('projects'); > __PACKAGE__->add_column(staffid => { is_foreign_key => 1 } ); > __PACKAGE__->add_columns(qw(projectname allocation)); > __PACKAGE__->set_primary_key('staffid', 'projectname'); > __PACKAGE__->belongs_to(staff => 'Staff::Schema::Result::Staff', 'staffid'); > 1; > > > The SQL I'm trying to generate is this: > > ? ? ? ?SELECT s.staffid, count(projectname) as numprojects > ? ? ? ?FROM staff s, projects p > ? ? ? ?WHERE p.staffid = s.staffid > ? ? ? ?GROUP BY s.staffid > ? ? ? ?ORDER BY numprojects DESC > > > I've tried a few things, but I just don't seem to be able to get this one to > work. ?Is it true that I'll have to reach out to the underlying dbi object to do > it? ?If so, how do I do that? I think something along the lines of: my $query = $schema->resultset('Staff')->search( { }, { join => 'projects', select => ['me.staffid', { count => 'projects.projectname' }] as => [qw(staffid projectnamecount)], group_by => 'projectname', } ); while (my $row = $query->next) { say $row->staffid . " has project count=" . $row->get_column('projectnamecount'); } ... which is, if anything, more convoluted than the original SQL. DBIx::Class works really well for dealing with bunches of rows as if they were objects, but not as well when it comes to reporting queries. I'd advise looking at the perldoc for ResultSource::View, and then creating a package that is one, which encapsulates the reporting query, or at least a generic version of it. Then you could do something like: my $query = $schema->resultset('Report::Staff'Projects')->search; Or to restrict it to certain staff, eg: my $query = $schema->resultset('Report::Staff'Projects')->search( { staffid => { '<' => 1000 } } ); Toby From jarich at perltraining.com.au Tue Sep 28 16:41:31 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Wed, 29 Sep 2010 09:41:31 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: References: <4CA1F507.3030505@perltraining.com.au> Message-ID: <4CA27D2B.3000507@perltraining.com.au> Toby Wintermute wrote: > I think something along the lines of: > my $query = $schema->resultset('Staff')->search( > { }, > { > join => 'projects', > select => ['me.staffid', { count => 'projects.projectname' }] > as => [qw(staffid projectnamecount)], > group_by => 'projectname', > } > ); > > while (my $row = $query->next) { > say $row->staffid . " has project count=" . > $row->get_column('projectnamecount'); > } Because I needed the order_by as well, I ended up doing this: my $query = $schema->resultset('Staff')->search( { }, { join => 'projects', select => ['me.staffid', { count => 'projects.projectname', -as => 'projectnamecount'} ], as => [qw(staffid projectnamecount)], group_by => 'me.staffid', order_by => 'projectnamecount', } ); while (my $row = $query->next) { print $row->staffid . " has project count=" . $row->get_column('projectnamecount'), "\n"; } But thank you so much for setting me on the right track! > DBIx::Class works really well for dealing with bunches of rows as if > they were objects, but not as well when it comes to reporting queries. That's exactly what I expected and what this example is intended to show. :) (In fact, this example is derived from a similar example I used for Class::DBI where there was _no_ way to create such a query via the object interface so you farmed it out towards DBI.) > I'd advise looking at the perldoc for ResultSource::View, and then > creating a package that is one, which encapsulates the reporting > query, or at least a generic version of it. > > Then you could do something like: > my $query = $schema->resultset('Report::Staff'Projects')->search; > Or to restrict it to certain staff, eg: > my $query = $schema->resultset('Report::Staff'Projects')->search( > { staffid => { '<' => 1000 } } > ); Great plan, and thanks again. I owe you a beer or cider. ;) 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 tjc at wintrmute.net Tue Sep 28 18:11:13 2010 From: tjc at wintrmute.net (Toby Wintermute) Date: Wed, 29 Sep 2010 11:11:13 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: <4CA27D2B.3000507@perltraining.com.au> References: <4CA1F507.3030505@perltraining.com.au> <4CA27D2B.3000507@perltraining.com.au> Message-ID: On 29 September 2010 09:41, Jacinta Richardson wrote: > Toby Wintermute wrote: [snip code] >> DBIx::Class works really well for dealing with bunches of rows as if >> they were objects, but not as well when it comes to reporting queries. > > That's exactly what I expected and what this example is intended to show. ?:) > (In fact, this example is derived from a similar example I used for Class::DBI > where there was _no_ way to create such a query via the object interface so you > farmed it out towards DBI.) May I solicit recommendations for Perl DB modules which *are* designed with creating reporting queries? A theoretical interface might be: my $reporter = DB::Report->new(schema => My::App::Schema->connect); my $result = $reporter->frequency_analysis( where => { staff_id > 1000 }, join => { 'Staff' => 'projects' } over => 'projects.projectname', ); And then I'd get back a frequency analysis of non-executive staff on projects. Toby From brendon.oliver at gmail.com Wed Sep 29 14:05:53 2010 From: brendon.oliver at gmail.com (Brendon Oliver) Date: Thu, 30 Sep 2010 07:05:53 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: References: <4CA1F507.3030505@perltraining.com.au> <4CA27D2B.3000507@perltraining.com.au> Message-ID: <4CA3AA31.1040608@gmail.com> On 29/09/2010 11:11 AM, Toby Wintermute wrote: > May I solicit recommendations for Perl DB modules which *are* designed > with creating reporting queries? Have you had a look at Rose::DB / Rose::DB::Object / Rose::DB::Object::Manager? I've just started using it in a project at work these last few weeks, so I'm still learning lots of things about it, but so far it's been extremely useful. I've not yet found anything that it can't cope with (but that's not saying much I guess). cheers, - Brendon From simon at unisolve.com.au Wed Sep 29 19:51:29 2010 From: simon at unisolve.com.au (Simon Taylor) Date: Thu, 30 Sep 2010 12:51:29 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: References: <4CA1F507.3030505@perltraining.com.au> Message-ID: <4CA3FB31.1020901@unisolve.com.au> Hello Toby, > DBIx::Class works really well for dealing with bunches of rows as if > they were objects, but not as well when it comes to reporting queries. > > I'd advise looking at the perldoc for ResultSource::View, and then > creating a package that is one, which encapsulates the reporting > query, or at least a generic version of it. > > Then you could do something like: > my $query = $schema->resultset('Report::Staff'Projects')->search; > Or to restrict it to certain staff, eg: > my $query = $schema->resultset('Report::Staff'Projects')->search( > { staffid => { '<' => 1000 } } > ); > > Thanks for this. I wasn't aware of ResultSource::View and we too are struggling with using DBIx::CLASS for reporting, but otherwise we're happy with it. Cheers, Simon From list at bereft.net Wed Sep 29 20:12:51 2010 From: list at bereft.net (Brad Bowman) Date: Thu, 30 Sep 2010 13:12:51 +1000 Subject: [Melbourne-pm] Any DBIx::Class gurus around? In-Reply-To: References: <4CA1F507.3030505@perltraining.com.au> <4CA27D2B.3000507@perltraining.com.au> Message-ID: <4CA40033.7010800@bereft.net> Toby Wintermute wrote: > On 29 September 2010 09:41, Jacinta Richardson > wrote: >> Toby Wintermute wrote: > [snip code] >>> DBIx::Class works really well for dealing with bunches of rows as if >>> they were objects, but not as well when it comes to reporting queries. >> That's exactly what I expected and what this example is intended to show. :) >> (In fact, this example is derived from a similar example I used for Class::DBI >> where there was _no_ way to create such a query via the object interface so you >> farmed it out towards DBI.) > > May I solicit recommendations for Perl DB modules which *are* designed > with creating reporting queries? DBIx::SQLCrosstab does cross-tabs http://search.cpan.org/~gmax/DBIx-SQLCrosstab-1.17/SQLCrosstab.pm > A theoretical interface might be: > my $reporter = DB::Report->new(schema => My::App::Schema->connect); > my $result = $reporter->frequency_analysis( > where => { staff_id > 1000 }, > join => { 'Staff' => 'projects' } > over => 'projects.projectname', > ); > > And then I'd get back a frequency analysis of non-executive staff on projects. >