From melbourne-pm at mjch.net Tue Feb 2 22:05:14 2010 From: melbourne-pm at mjch.net (Malcolm Herbert) Date: Wed, 03 Feb 2010 17:05:14 +1100 Subject: [Melbourne-pm] creating portable bundles of modules In-Reply-To: References: Message-ID: <1265177114.18707.1357997801@webmail.messagingengine.com> I have a need to be able to bundle a few CPAN-sourced modules together with some of my own code for both NetBSD and Linux of various flavours. What's the best method for doing this? On my own systems I'm using pkgsrc to do the heavy-lifting here, however that's only because I have admin on my local hosts - I won't have root access on the remote Linux hosts I'm installing on and am a little lost as to how to go about it all without it ... :) I'm aware that I will probably need to do some per-environment setup for each Perl module and would prefer to automate this as much as possible. ... the complication is that I probably won't be able to run a compiler toolchain on the remote hosts as they're not development boxes either, so some modules could be impossible to install in-situ ... How have people solved this issue in the past? Regards, Malcolm -- Malcolm Herbert This brain intentionally mjch at mjch.net left blank From toby.corkindale at strategicdata.com.au Tue Feb 2 22:20:59 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 03 Feb 2010 17:20:59 +1100 Subject: [Melbourne-pm] creating portable bundles of modules In-Reply-To: <1265177114.18707.1357997801@webmail.messagingengine.com> References: <1265177114.18707.1357997801@webmail.messagingengine.com> Message-ID: <4B6915CB.5020601@strategicdata.com.au> On 03/02/10 17:05, Malcolm Herbert wrote: > I have a need to be able to bundle a few CPAN-sourced modules together > with some of my own code for both NetBSD and Linux of various flavours. > What's the best method for doing this? You could package them into, well, packages, to suit the destination machines. Which is painful enough when you're only doing it for one version of one distribution, and absolutely inhumane to consider for a whole collection of targets, as in your case. Another option is PAR, which bundles everything, including the interpreter, into a single executeable. This does mean you can use the same PAR on many distributions, but will still need versions for i386 vs amd64, and probably bsd vs linux too, unless one of the binary compatibility layers can come to the party. You can also use local::lib, but again, still needs versions being built for the various architectures. Both PAR and local::lib will allow multiple architectures to be installed alongside each other, which is great, if you're patient enough to compile them all. Better yet, attempt to do everything in pure-perl with no XS. -T From ddick at iinet.net.au Tue Feb 2 23:54:26 2010 From: ddick at iinet.net.au (David Dick) Date: Wed, 03 Feb 2010 18:54:26 +1100 Subject: [Melbourne-pm] creating portable bundles of modules In-Reply-To: <1265177114.18707.1357997801@webmail.messagingengine.com> References: <1265177114.18707.1357997801@webmail.messagingengine.com> Message-ID: <4B692BB2.4060809@iinet.net.au> On 03/02/10 17:05, Malcolm Herbert wrote: > I have a need to be able to bundle a few CPAN-sourced modules together > with some of my own code for both NetBSD and Linux of various flavours. > What's the best method for doing this? *snip* > How have people solved this issue in the past? I would second Toby's recommendation of PAR. Last time i was looking how to distribute perl modules without root access, Skud had a good blog on the subject a while back at http://infotrope.net/blog/2007/07/17/cpan-and-the-installability-crisis/ From toby.corkindale at strategicdata.com.au Wed Feb 3 19:00:34 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 04 Feb 2010 14:00:34 +1100 Subject: [Melbourne-pm] No, really.. Message-ID: <4B6A3852.9040202@strategicdata.com.au> CPANPLUS has a configuration option, allow_build_interactivity. It defaults to true, but I really don't want to get pestered by questions like "should I install these dependencies?". I've already told it to always install deps without asking, but some module::install scripts prompt independently. However, despite setting allow_build_interactivity to 0, I still get prompted by quite a lot of modules. Is there a way to say "No, *really* don't ask me, just use the default!"? It's annoying to start something that builds/installs a thousand CPAN modules, and have to babysit the process, hitting enter occasionally.. Toby -- Strategic Data Pty Ltd Ph: 03 9340 9000 From pat at patspam.com Wed Feb 3 19:57:03 2010 From: pat at patspam.com (Patrick Donelan) Date: Thu, 4 Feb 2010 14:57:03 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <4B6A3852.9040202@strategicdata.com.au> References: <4B6A3852.9040202@strategicdata.com.au> Message-ID: <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> Hey Toby, Do you remember which CPAN module caused this? It'd be interesting to see if it's using Module::Install or Module::Build (or something else) and trace back from the Makefile.PL or whatever. I remember this happening in the past with the CPAN shell despite setting * prerequisites_policy* and *build_requires_install_policy*, but I don't think it's happened to me recently (not sure if it was fixed or just coincidence). Cheers, Patrick On Thu, Feb 4, 2010 at 2:00 PM, Toby Corkindale < toby.corkindale at strategicdata.com.au> wrote: > CPANPLUS has a configuration option, allow_build_interactivity. > It defaults to true, but I really don't want to get pestered by questions > like "should I install these dependencies?". > I've already told it to always install deps without asking, but some > module::install scripts prompt independently. > > However, despite setting allow_build_interactivity to 0, I still get > prompted by quite a lot of modules. > > Is there a way to say "No, *really* don't ask me, just use the default!"? > > It's annoying to start something that builds/installs a thousand CPAN > modules, and have to babysit the process, hitting enter occasionally.. > > Toby > > -- > Strategic Data Pty Ltd > Ph: 03 9340 9000 > _______________________________________________ > 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 toby.corkindale at strategicdata.com.au Wed Feb 3 20:04:40 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 04 Feb 2010 15:04:40 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> References: <4B6A3852.9040202@strategicdata.com.au> <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> Message-ID: <4B6A4758.2090303@strategicdata.com.au> On 04/02/10 14:57, Patrick Donelan wrote: > Hey Toby, > > Do you remember which CPAN module caused this? It'd be interesting to > see if it's using Module::Install or Module::Build (or something else) > and trace back from the Makefile.PL or whatever. Many, many modules :( You know how Module::Install packages will prompt you "Do you want to install these mandatory dependencies? [y]"? It's that. I'm like, why yes, yes I do, but why for the love of god isn't there an "a" option, meaning "yes, and do this for [A]ll in the future." :( They're mandatory requirements, so it seems barely worth asking me, it's not like it's going to work otherwise.. And because I don't want to be there to make a selection, I'd rather like the optional requirements to get "Y" as well, but would be happy to have them auto-no-ed too, rather than it pausing altogether.. > I remember this happening in the past with the CPAN shell despite > setting *prerequisites_policy* and *build_requires_install_policy*, but > I don't think it's happened to me recently (not sure if it was fixed or > just coincidence). try "cpanp i Task::Kensho" and let me know how you go? :) Cheers, Toby From alfiejohn at gmail.com Wed Feb 3 20:39:04 2010 From: alfiejohn at gmail.com (Alfie John) Date: Thu, 4 Feb 2010 15:39:04 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <4B6A4758.2090303@strategicdata.com.au> References: <4B6A3852.9040202@strategicdata.com.au> <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> <4B6A4758.2090303@strategicdata.com.au> Message-ID: Hey folks, Many, many modules :( > You know how Module::Install packages will prompt you "Do you want to > install these mandatory dependencies? [y]"? It's that. > I'm like, why yes, yes I do, but why for the love of god isn't there an "a" > option, meaning "yes, and do this for [A]ll in the future." :( > I submitted a patch a while back on Perl5 Porters which did that exact feature. There was praise for it, but unfortunately wasn't accepted from bleed. The reasoning was I should have instead changed my cpan settings. WTF I know. I don't have any sway on P5P. But maybe somebody reading this can try again (looking at you *Paul* :) You can find the Perl5 Porters discussion here: http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/3779444 And the patch here: http://github.com/alfie/perl/tree/cpan_always Alfie -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfiejohn at gmail.com Wed Feb 3 20:41:17 2010 From: alfiejohn at gmail.com (Alfie John) Date: Thu, 4 Feb 2010 15:41:17 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: References: <4B6A3852.9040202@strategicdata.com.au> <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> <4B6A4758.2090303@strategicdata.com.au> Message-ID: BTW: GitHub is down right now, so you might want to retry a bit later. See their twitter status for more info: http://twitter.com/github Alfie On Thu, Feb 4, 2010 at 3:39 PM, Alfie John wrote: > Hey folks, > > Many, many modules :( >> You know how Module::Install packages will prompt you "Do you want to >> install these mandatory dependencies? [y]"? It's that. >> I'm like, why yes, yes I do, but why for the love of god isn't there an >> "a" option, meaning "yes, and do this for [A]ll in the future." :( >> > > I submitted a patch a while back on Perl5 Porters which did that exact > feature. There was praise for it, but unfortunately wasn't accepted from > bleed. The reasoning was I should have instead changed my cpan settings. > > WTF I know. I don't have any sway on P5P. But maybe somebody reading this > can try again (looking at you *Paul* :) > > You can find the Perl5 Porters discussion here: > > http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/3779444 > > And the patch here: > > http://github.com/alfie/perl/tree/cpan_always > > Alfie > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shlomif at iglu.org.il Thu Feb 4 00:46:31 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Thu, 4 Feb 2010 10:46:31 +0200 Subject: [Melbourne-pm] No, really.. In-Reply-To: <4B6A3852.9040202@strategicdata.com.au> References: <4B6A3852.9040202@strategicdata.com.au> Message-ID: <201002041046.32432.shlomif@iglu.org.il> Hi Toby! On Thursday 04 Feb 2010 05:00:34 Toby Corkindale wrote: > CPANPLUS has a configuration option, allow_build_interactivity. > It defaults to true, but I really don't want to get pestered by > questions like "should I install these dependencies?". > I've already told it to always install deps without asking, but some > module::install scripts prompt independently. > > However, despite setting allow_build_interactivity to 0, I still get > prompted by quite a lot of modules. > > Is there a way to say "No, *really* don't ask me, just use the default!"? > What I do is, in my .bash_profile or .bashrc: <<< export PERL_AUTOINSTALL="--alldeps" export PERL_MM_USE_DEFAULT=1 >>> Hope it helps. Regards, Shlomi Fish > It's annoying to start something that builds/installs a thousand CPAN > modules, and have to babysit the process, hitting enter occasionally.. > > Toby -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "Star Trek: We, the Living Dead" - http://shlom.in/st-wtld Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . From pat at patspam.com Thu Feb 4 04:59:27 2010 From: pat at patspam.com (Patrick Donelan) Date: Thu, 4 Feb 2010 23:59:27 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <201002041046.32432.shlomif@iglu.org.il> References: <4B6A3852.9040202@strategicdata.com.au> <201002041046.32432.shlomif@iglu.org.il> Message-ID: <42321ee21002040459t61f6a197gb0d2cfb99185a8d8@mail.gmail.com> Not sure if this shines any more light on it.. (15:41:02) patspam: Alias__: is there any cpan or cpanplus option that will make Module::AutoInstall's feature() install prereqs without asking? (15:41:18) Alias__: Nope (15:41:26) patspam: by design? (15:41:30) Alias__: Yup (15:41:32) Alias__: Well (15:41:47) Alias__: It's by design that the Makefile.PL runs based on the logic of the version of M:I that the author originally packaged it with (15:42:18) Alias__: So really, if you have some annoying Makefile.PL that don't follow the CPAN client's defaulting and ask/follow policy, you need to get a new incremental release of those modules (15:42:58) patspam: say for something like Task::Kensho (15:43:15) patspam: can I stop it from asking me: Auto-install the 1 optional module(s) from CPAN? [y] (15:44:02) patspam: prerequisites_policy doesn't seem to do the trick (15:44:44) patspam: (asking because people on Melb.PM mailing list are musing about it) (15:46:22) Hyppolit: svn: r10496 | adamk++ | http://padre.perlide.org/trac/changeset/10496 (I think at this point Adam got distracted committing some cool new Padre feature and hence I didn't get a follow-up response) On Thu, Feb 4, 2010 at 7:46 PM, Shlomi Fish wrote: > Hi Toby! > > On Thursday 04 Feb 2010 05:00:34 Toby Corkindale wrote: > > CPANPLUS has a configuration option, allow_build_interactivity. > > It defaults to true, but I really don't want to get pestered by > > questions like "should I install these dependencies?". > > I've already told it to always install deps without asking, but some > > module::install scripts prompt independently. > > > > However, despite setting allow_build_interactivity to 0, I still get > > prompted by quite a lot of modules. > > > > Is there a way to say "No, *really* don't ask me, just use the default!"? > > > > What I do is, in my .bash_profile or .bashrc: > > <<< > > export PERL_AUTOINSTALL="--alldeps" > export PERL_MM_USE_DEFAULT=1 > > >>> > > Hope it helps. > > Regards, > > Shlomi Fish > > > It's annoying to start something that builds/installs a thousand CPAN > > modules, and have to babysit the process, hitting enter occasionally.. > > > > Toby > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > "Star Trek: We, the Living Dead" - http://shlom.in/st-wtld > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > 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 cas at taz.net.au Sat Feb 6 04:11:49 2010 From: cas at taz.net.au (Craig Sanders) Date: Sat, 6 Feb 2010 23:11:49 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <4B6A3852.9040202@strategicdata.com.au> References: <4B6A3852.9040202@strategicdata.com.au> Message-ID: <20100206121149.GA23304@taz.net.au> On Thu, Feb 04, 2010 at 02:00:34PM +1100, Toby Corkindale wrote: > It's annoying to start something that builds/installs a thousand > CPAN modules, and have to babysit the process, hitting enter > occasionally.. in the absence of any real fix to this, it sounds like a job for Expect.pm or similar. craig -- craig sanders From sam at nipl.net Sat Feb 6 04:47:22 2010 From: sam at nipl.net (Sam Watkins) Date: Sat, 6 Feb 2010 23:47:22 +1100 Subject: [Melbourne-pm] No, really.. In-Reply-To: <20100206121149.GA23304@taz.net.au> References: <4B6A3852.9040202@strategicdata.com.au> <20100206121149.GA23304@taz.net.au> Message-ID: <20100206124722.GB5300@nipl.net> Toby Corkindale wrote: > It's annoying to start something that builds/installs a thousand > CPAN modules, and have to babysit the process, hitting enter > occasionally.. It sounds to me like CPAN should change its policy so that fully automatic installs, and to require authors to upgrade existing modules or be excluded from the CPAN. It would be a big job to fix them all I guess. Craig Sanders wrote: > in the absence of any real fix to this, it sounds like a > job for Expect.pm or similar. or maybe just: yes '' Sam From jarich at perltraining.com.au Mon Feb 8 03:45:22 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 08 Feb 2010 22:45:22 +1100 Subject: [Melbourne-pm] OSDClub/Melbourne Perl Monger meeting WEDNESDAY (10th February 2010) Message-ID: <4B6FF952.8040801@perltraining.com.au> G'day folk, The Open Source Developers' Club is a group designed to bring Melbourne's great developer community together, regardless of whether they write code in Perl, Python, PHP, Ruby or something else. Talks are designed to share information about things which are meta issues to our programming; such as database interactions, javascript testing tools, tricks of our trade etc. It is hosted every two months and shared between the Melbourne Perl Mongers group and the Melbourne PHP Programmers. Cheryl Davis from EvoStor has kindly arranged for us to use their premises for the next meeting. EvoStor is a technology start-up developing storage systems specifically designed to meet the challenges of storage for virtual infrastructure. All of the engineering work is done out of Melbourne with the corporate headquarters in California. So a huge thank you to Cheryl and EvoStor! Please join us at 6:30pm, this Wednesday 10th February 2010 at: Level 10, 350 Collins Street, Melbourne (EvoStor side of the floor) The doors will be locked, but I will be there to help let you in. If you are running late, please look out for the note with the phone number you should ring to be let in. Talks should start at about 6:45pm. Talks: -------- Scott Penrose: ExtJS and OpenLayers (30 minutes) Patrick Donelan: Tricking People Into Thinking Your Website is Fast: WebGUI and YSlow, 100 or bust! (30 minutes) Suggestions for food places after the meeting are welcome. I look forward to seeing you there. J From sam at nipl.net Mon Feb 8 20:25:17 2010 From: sam at nipl.net (Sam Watkins) Date: Tue, 9 Feb 2010 15:25:17 +1100 Subject: [Melbourne-pm] Facebook::Slurp, Filter::Self Message-ID: <20100209042517.GB8307@nipl.net> hi, I'm writing a program in Perl to incrementally "slurp" data from facebook, to nice YAML and TSV files (like wget -c). It's not finished yet but it is working for profile info and streams (your wall, others' walls, status updates feed). I haven't got it to slurp comments yet. The streams are presented as simple readable TSV files, for use with grep, etc, having lines like this: 2010/02/06 01:03:54 Sam Watkins uploaded my first video to youtube, it's a funny thing I did with a flash game "Cargo Bridge" (armor games edition): http://www.youtube.com/watch?v=uguxuuAn4qo The date comes first and is sortable! (unlike apache logs) so it's a simple matter to merge several streams for example. Thanks to PJF for his facebook example script which was very helpful with getting started. I'll post again when I've finished it. I also wrote Filter::Self last night, it uses Damien's Filter::Simple to add some nicer OO / function call syntax to perl. This has I suppose been done before, anyway you can do things like this: this code: becomes: ---------- -------- print .name; print $self->{name}; .recalc($alpha); $self->recalc($alpha); sub say($str) { sub say { my ($str) = @_; sub .recalc($alpha) { sub recalc { my ($self, $alpha) = @_; shift; print .foo.bar.baz; print $self->{foo}{bar}{baz}; I think that makes it a lot easier / briefer to do OO in perl, it's more like java, actually sort of inspired by visual basic! I like this syntax anyway. This is pretty much finished, and there is a tgz here: http://sam.nipl.net/code/filter-self/ Please let me know what you think of it. I also got a new job programming perl recently, which is good. I should also try to get an author account or whatever on CPAN I guess. Sam From drew at drewtaylor.com Tue Feb 9 01:30:22 2010 From: drew at drewtaylor.com (Drew Taylor) Date: Tue, 9 Feb 2010 09:30:22 +0000 Subject: [Melbourne-pm] Facebook::Slurp, Filter::Self In-Reply-To: <20100209042517.GB8307@nipl.net> References: <20100209042517.GB8307@nipl.net> Message-ID: I'm not in Melbourne (give me a few years), but I thought I'd put in my ?0.02. You might also want to look into Moose and/or MooseX::Declare. Mx::D gives you some nice syntax for defining methods and the parameters passed, while Moose gives you a nicer OO interface. Regarding source filtering, Just Don't Do It. Ricardo Signes' review of Filter::Simple says it all: "Don't write source filters. They will make your momma cry." Moose (or perhaps Devel::Declare if you want to go really low-level) is a much better way to achieve the same effect and keep you sane. :-) Drew On Tue, Feb 9, 2010 at 4:25 AM, Sam Watkins wrote: > hi, > > I'm writing a program in Perl to incrementally "slurp" data from > facebook, to nice YAML and TSV files (like wget -c). It's not finished > yet but it is working for profile info and streams (your wall, others' > walls, status updates feed). I haven't got it to slurp comments yet. > > The streams are presented as simple readable TSV files, for use with > grep, etc, having lines like this: > > 2010/02/06 01:03:54 Sam Watkins uploaded my first video to youtube, > it's a funny thing I did with a flash game "Cargo Bridge" (armor games > edition): http://www.youtube.com/watch?v=uguxuuAn4qo > > The date comes first and is sortable! (unlike apache logs) so it's a > simple matter to merge several streams for example. > > Thanks to PJF for his facebook example script which was very helpful > with getting started. I'll post again when I've finished it. > > > I also wrote Filter::Self last night, it uses Damien's Filter::Simple to > add some nicer OO / function call syntax to perl. This has I suppose > been done before, anyway you can do things like this: > > this code: becomes: > ---------- -------- > print .name; print $self->{name}; > .recalc($alpha); $self->recalc($alpha); > sub say($str) { sub say { > my ($str) = @_; > sub .recalc($alpha) { sub recalc { > my ($self, $alpha) = @_; shift; > print .foo.bar.baz; print $self->{foo}{bar}{baz}; > > I think that makes it a lot easier / briefer to do OO in perl, it's more > like java, actually sort of inspired by visual basic! I like this > syntax anyway. This is pretty much finished, and there is a tgz here: > > http://sam.nipl.net/code/filter-self/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarich at perltraining.com.au Tue Feb 9 20:06:15 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Wed, 10 Feb 2010 15:06:15 +1100 Subject: [Melbourne-pm] OSDClub/Melbourne Perl Monger meeting TONIGHT (10th February 2010) Message-ID: <4B7230B7.20706@perltraining.com.au> G'day folk, The Open Source Developers' Club meeting is on tonight, hosted by Melbourne Perl Mongers. Please join us at 6:30pm at: Level 10, 350 Collins Street, Melbourne (EvoStor side of the floor) The doors will be locked, but someone will be there to help let you in. If you are running late, please look out for the note with the phone number you should ring to be let in. Talks should start at about 6:45pm, but please try to arrive by 6:30pm. Talks: -------- Scott Penrose: ExtJS and OpenLayers (30 minutes) Patrick Donelan: Tricking People Into Thinking Your Website is Fast: WebGUI and YSlow, 100 or bust! (30 minutes) Tony Smith: Map-centric, collaborative content creation for the community sector. (10 minutes) Request for help: ------------------ I may not be able to make it to the meeting. If you'll be in the city from about 6:15pm, would you please consider heading over to EvoStor and keeping the EvoStor employee company and helping let people into the building? I'd really appreciate it! General information --------------------- The Open Source Developers' Club is a group designed to bring Melbourne's great developer community together, regardless of whether they write code in Perl, Python, PHP, Ruby or something else. Talks are designed to share information about things which are meta issues to our programming; such as database interactions, javascript testing tools, tricks of our trade etc. It is hosted every two months and shared between the Melbourne Perl Mongers group and the Melbourne PHP Programmers. Cheryl Davis from EvoStor has kindly arranged for us to use their premises for the next meeting. EvoStor is a technology start-up developing storage systems specifically designed to meet the challenges of storage for virtual infrastructure. All of the engineering work is done out of Melbourne with the corporate headquarters in California. So a huge thank you to Cheryl and EvoStor! From pjf at perltraining.com.au Wed Feb 10 00:01:59 2010 From: pjf at perltraining.com.au (Paul Fenwick) Date: Wed, 10 Feb 2010 19:01:59 +1100 Subject: [Melbourne-pm] OSDClub/Melbourne Perl Monger meeting TONIGHT (10th February 2010) In-Reply-To: <4B7230B7.20706@perltraining.com.au> References: <4B7230B7.20706@perltraining.com.au> Message-ID: <4B7267F7.7010102@perltraining.com.au> G'day Everone, As you've probably discovered, I'm unable to make tonight's meeting due to some tight deadlines and a crazy international travel schedule. I hope you're all having a great time without me! Paul -- 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 Mon Feb 15 17:10:26 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 16 Feb 2010 12:10:26 +1100 Subject: [Melbourne-pm] Smart-matching objects Message-ID: <4B79F082.3020900@strategicdata.com.au> A little gotcha about smart matching of objects in 5.10.0 vs 5.10.1: In both, you can attempt to match two blessed objects, eg: if ($person ~~ @people) .. In 5.10.0, this will do a useless comparison that definitely won't do what you want. In 5.10.1, this will fail altogether, unless you define an overloaded smartmatch operation in the objects. But if you DO define an overloaded smart match, then the behaviour varies. This is the syntax for overloading the smart match operator: use overload '~~' => sub { my ($left, $right) = @_; ... } In 5.10.0, you will receive the verbatim items from the left and right of the ~~ in your code, ie: $left = $person $right = $people[0] (followed by the rest of @people if you keep shifting) Or if you did ($person ~~ \@people) you would get: $left = $person $right = \@people However in 5.10.1, they (sensibly, I think) expand stuff out a bit, so you will have your matching subroutine called multiple times, ie: $left = $person, $right = $people[0] $left = $person, $right = $people[1] $left = $person, $right = $people[2] I'd prefer to just code for the 5.10.1 syntax and not look back, but I think it's only in private projects that I have the luxury of being able to set "use 5.10.1;" at the top of my scripts ;) tjc. From sam at nipl.net Thu Feb 18 15:16:20 2010 From: sam at nipl.net (Sam Watkins) Date: Thu, 18 Feb 2010 23:16:20 +0000 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: References: <20100209042517.GB8307@nipl.net> Message-ID: <20100218231620.GA27378@nipl.net> A quick question. Supposing I want to return an array from my_func(), I can do like: ... return @foo; } @foo = my_func(); but I normally do it like this because I feel like it should be more efficient: ... return \@foo; } $foo = my_func(); This has the unfortunate effect of converting my array to an array ref. If I wanted to reverse that, I think I could use: @foo = @{my_func()}; which is getting ugly and inefficient too. The same thing happens when returning hash variables, except that I suppose it is even more inefficient to return it via a list return compared to a reference. My question is, does perl actually optimize this so it sucks less than I am naively supposing it does? Also, is there any way to make like an alias @foo for @$foo, so you can treat an array reference as a normal array without writing @$foo all the time? (and also for hashes) These concerns make me reluctant to use normal perl @array and %hash types at all. If I have to pass and return things by reference, and can't alias these back to normal @array and %hash types, I would prefer to use references for everything in order to be consistent and avoid having to rewrite code when I suddenly need to pass some variable to or from a sub. This would make the @foo %bar syntax useless for anything but the one-liners. So I'm hoping there is some workaround or optimization, and a way to alias them. thanks! On Tue, Feb 09, 2010 at 09:30:22AM +0000, Drew Taylor wrote: > I'm not in Melbourne (give me a few years), but I thought I'd put in my > ?0.02. > > You might also want to look into Moose and/or MooseX::Declare. Mx::D gives > you some nice syntax for defining methods and the parameters passed, while > Moose gives you a nicer OO interface. Mx::D looks good. It still apparently uses $self->{foo} for accessing members though, which is what my filter avoids. They are orthogonal! > Regarding source filtering, Just Don't Do It. Ricardo Signes' review of > Filter::Simple says it all: "Don't write source filters. They will make your > momma cry." I'm sure my momma would cry, scream and tear her hair out if she experienced even a little of the horror of perl programming. If a tiny source filter is what it takes to negate some of that horror, I'm happy to use one. Or a more positive rationale: perl is all about hideous crazy fun hacks, so I'm just fitting in with the scene. I think a source filter is just a simple translator / compiler module. If it's done right, it can really improve the language. They can be written with the aid of proper parsers (although it's doubtful if such a thing exists for perl, Damien's stuff is good enough for non-pathological well-written programs). I've written plenty of source filters for C (my "brace" project is implemented as a composition of filters) and a couple for perl. I think it's an elegant thing. Look at troff for example, it has nice little modules like eqn and tbl for different stuff. eqn syntax is on a par with TeX for simplicity, it is much simpler than MathML (horror!). troff syntax might seem a bit ugly but tbl syntax for example is a lot more readable than HTML tables. Have you read the excellent book "The Practice of Programming" by Kernighan and Pike? "This book was typeset (grap|pic|tbl|eqn|troff -mpm) in Times and Lucida San Typewriter by the authors." http://www.troff.org/pubs.html#tpop Admittedly troff has nowhere near the following of TeX (except for man pages). I'd like to see the source of that book, and compare it to say "the TeX book". It's kind of nice to use filters, you can turn them on and off or apply just one filter to test it. You can pipe them together in whatever order works best, at least if you do it using make or the shell, I think Filter::Simple can stack them too but I didn't try it. It's a very modular / unixy way to do things: simple processes communicating via text pipes. I think this is still the most expressive programming paradigm to date. An improvement would be to integrate the ideas of make (cache intermediate data in files, compute only what's needed) and the shell (pipelines of processes running in parallel); perhaps with a graphical nodes-and-arcs interface that maps <-> a clear textual format. To create such a language is an ambition of mine! Using textual formats may be seen as inefficient: binary formats (e.g. packet streams of raw structs) may be used as an optimization so long as the textual version can be generated on the fly as needed, for inspection / debugging / portability or whatever. Something like YAML might serve admirably for that purpose, or even use the format like Debian metadata files, with refs instead of nesting: name: Sam sex: m name: Maria sex: f I should probably do some work now! Sam From toby.corkindale at strategicdata.com.au Thu Feb 18 16:27:45 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Fri, 19 Feb 2010 11:27:45 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <20100218231620.GA27378@nipl.net> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> Message-ID: <4B7DDB01.1080402@strategicdata.com.au> On 19/02/10 10:16, Sam Watkins wrote: > A quick question. Supposing I want to return an array from my_func(), I can do > like: > > ... > return @foo; > } > > @foo = my_func(); > > but I normally do it like this because I feel like it should be more efficient: > > ... > return \@foo; > } > > $foo = my_func(); > > This has the unfortunate effect of converting my array to an array ref. If I > wanted to reverse that, I think I could use: > > @foo = @{my_func()}; > > which is getting ugly and inefficient too. The same thing happens when > returning hash variables, except that I suppose it is even more inefficient to > return it via a list return compared to a reference. > > My question is, does perl actually optimize this so it sucks less than I am > naively supposing it does? Also, is there any way to make like an alias @foo > for @$foo, so you can treat an array reference as a normal array without > writing @$foo all the time? (and also for hashes) No, Perl does not optimise it for you, so returning references is definitely better for performance. There isn't any language syntax for the aliasing you're talking about either. > These concerns make me reluctant to use normal perl @array and %hash types at > all. If I have to pass and return things by reference, and can't alias these > back to normal @array and %hash types, I would prefer to use references for > everything in order to be consistent and avoid having to rewrite code when I > suddenly need to pass some variable to or from a sub. This would make the @foo > %bar syntax useless for anything but the one-liners. So I'm hoping there is > some workaround or optimization, and a way to alias them. Luckily there is. Use the Moose. I think Drew mentioned that in the quoted but unrelated text I cut from the bottom of this email. Have you investigated Moose yet? Cheers, Toby From alfiejohn at gmail.com Thu Feb 18 16:41:11 2010 From: alfiejohn at gmail.com (Alfie John) Date: Fri, 19 Feb 2010 11:41:11 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <4B7DDB01.1080402@strategicdata.com.au> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> <4B7DDB01.1080402@strategicdata.com.au> Message-ID: I know it's a bit evil, but you could probably hook into Perl magic (see perlguts): foreach my $person ( $people ) { ... } Here, $people is a magic perl variable which checks what context it is being used in. However, it's evil so forget I said anything. Alfie On Fri, Feb 19, 2010 at 11:27 AM, Toby Corkindale < toby.corkindale at strategicdata.com.au> wrote: > On 19/02/10 10:16, Sam Watkins wrote: > >> A quick question. Supposing I want to return an array from my_func(), I >> can do >> like: >> >> ... >> return @foo; >> } >> >> @foo = my_func(); >> >> but I normally do it like this because I feel like it should be more >> efficient: >> >> ... >> return \@foo; >> } >> >> $foo = my_func(); >> >> This has the unfortunate effect of converting my array to an array ref. >> If I >> wanted to reverse that, I think I could use: >> >> @foo = @{my_func()}; >> >> which is getting ugly and inefficient too. The same thing happens when >> returning hash variables, except that I suppose it is even more >> inefficient to >> return it via a list return compared to a reference. >> >> My question is, does perl actually optimize this so it sucks less than I >> am >> naively supposing it does? Also, is there any way to make like an alias >> @foo >> for @$foo, so you can treat an array reference as a normal array without >> writing @$foo all the time? (and also for hashes) >> > > No, Perl does not optimise it for you, so returning references is > definitely better for performance. > There isn't any language syntax for the aliasing you're talking about > either. > > > These concerns make me reluctant to use normal perl @array and %hash types >> at >> all. If I have to pass and return things by reference, and can't alias >> these >> back to normal @array and %hash types, I would prefer to use references >> for >> everything in order to be consistent and avoid having to rewrite code when >> I >> suddenly need to pass some variable to or from a sub. This would make the >> @foo >> %bar syntax useless for anything but the one-liners. So I'm hoping there >> is >> some workaround or optimization, and a way to alias them. >> > > Luckily there is. Use the Moose. I think Drew mentioned that in the quoted > but unrelated text I cut from the bottom of this email. Have you > investigated Moose yet? > > Cheers, > Toby > > _______________________________________________ > 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 david.tulloh at AirservicesAustralia.com Thu Feb 18 16:49:29 2010 From: david.tulloh at AirservicesAustralia.com (Tulloh, David) Date: Fri, 19 Feb 2010 11:49:29 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <20100218231620.GA27378@nipl.net> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> Message-ID: When in doubt benchmark, it's difficult to guess at the internal workings of a interpretted language. I ran the attached benchmark and found returning @foo was faster than \@foo. The difference is trivial though and I would suggest using whatever format works best for you and then standardising on it. I personally use return @foo because I like passing the output into list functions like grep and map (@bar = map {} grep {} my_sub) and it's cleaner without the @{} everywhere. Directly working with array references is similar to hashes, $ref->[0]. David -----Original Message----- From: melbourne-pm-bounces+david.tulloh=airservices.gov.au at pm.org [mailto:melbourne-pm-bounces+david.tulloh=airservices.gov.au at pm.org] On Behalf Of Sam Watkins Sent: Friday, 19 February 2010 10:16 AM To: Melbourne Perlmongers Subject: [Melbourne-pm] returning hashes and arrays,source filters considered harmful? A quick question. Supposing I want to return an array from my_func(), I can do like: ... return @foo; } @foo = my_func(); but I normally do it like this because I feel like it should be more efficient: ... return \@foo; } $foo = my_func(); This has the unfortunate effect of converting my array to an array ref. If I wanted to reverse that, I think I could use: @foo = @{my_func()}; which is getting ugly and inefficient too. The same thing happens when returning hash variables, except that I suppose it is even more inefficient to return it via a list return compared to a reference. My question is, does perl actually optimize this so it sucks less than I am naively supposing it does? Also, is there any way to make like an alias @foo for @$foo, so you can treat an array reference as a normal array without writing @$foo all the time? (and also for hashes) These concerns make me reluctant to use normal perl @array and %hash types at all. If I have to pass and return things by reference, and can't alias these back to normal @array and %hash types, I would prefer to use references for everything in order to be consistent and avoid having to rewrite code when I suddenly need to pass some variable to or from a sub. This would make the @foo %bar syntax useless for anything but the one-liners. So I'm hoping there is some workaround or optimization, and a way to alias them. thanks! On Tue, Feb 09, 2010 at 09:30:22AM +0000, Drew Taylor wrote: > I'm not in Melbourne (give me a few years), but I thought I'd put in > my ?0.02. > > You might also want to look into Moose and/or MooseX::Declare. Mx::D > gives you some nice syntax for defining methods and the parameters > passed, while Moose gives you a nicer OO interface. Mx::D looks good. It still apparently uses $self->{foo} for accessing members though, which is what my filter avoids. They are orthogonal! > Regarding source filtering, Just Don't Do It. Ricardo Signes' review > of Filter::Simple says it all: "Don't write source filters. They will > make your momma cry." I'm sure my momma would cry, scream and tear her hair out if she experienced even a little of the horror of perl programming. If a tiny source filter is what it takes to negate some of that horror, I'm happy to use one. Or a more positive rationale: perl is all about hideous crazy fun hacks, so I'm just fitting in with the scene. I think a source filter is just a simple translator / compiler module. If it's done right, it can really improve the language. They can be written with the aid of proper parsers (although it's doubtful if such a thing exists for perl, Damien's stuff is good enough for non-pathological well-written programs). I've written plenty of source filters for C (my "brace" project is implemented as a composition of filters) and a couple for perl. I think it's an elegant thing. Look at troff for example, it has nice little modules like eqn and tbl for different stuff. eqn syntax is on a par with TeX for simplicity, it is much simpler than MathML (horror!). troff syntax might seem a bit ugly but tbl syntax for example is a lot more readable than HTML tables. Have you read the excellent book "The Practice of Programming" by Kernighan and Pike? "This book was typeset (grap|pic|tbl|eqn|troff -mpm) in Times and Lucida San Typewriter by the authors." http://www.troff.org/pubs.html#tpop Admittedly troff has nowhere near the following of TeX (except for man pages). I'd like to see the source of that book, and compare it to say "the TeX book". It's kind of nice to use filters, you can turn them on and off or apply just one filter to test it. You can pipe them together in whatever order works best, at least if you do it using make or the shell, I think Filter::Simple can stack them too but I didn't try it. It's a very modular / unixy way to do things: simple processes communicating via text pipes. I think this is still the most expressive programming paradigm to date. An improvement would be to integrate the ideas of make (cache intermediate data in files, compute only what's needed) and the shell (pipelines of processes running in parallel); perhaps with a graphical nodes-and-arcs interface that maps <-> a clear textual format. To create such a language is an ambition of mine! Using textual formats may be seen as inefficient: binary formats (e.g. packet streams of raw structs) may be used as an optimization so long as the textual version can be generated on the fly as needed, for inspection / debugging / portability or whatever. Something like YAML might serve admirably for that purpose, or even use the format like Debian metadata files, with refs instead of nesting: name: Sam sex: m name: Maria sex: f I should probably do some work now! Sam _______________________________________________ Melbourne-pm mailing list Melbourne-pm at pm.org http://mail.pm.org/mailman/listinfo/melbourne-pm -------------- next part -------------- A non-text attachment was scrubbed... Name: array_return_benchmark.pl Type: application/octet-stream Size: 304 bytes Desc: array_return_benchmark.pl URL: From toby.corkindale at strategicdata.com.au Thu Feb 18 17:01:52 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Fri, 19 Feb 2010 12:01:52 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> Message-ID: <4B7DE300.8020705@strategicdata.com.au> On 19/02/10 11:49, Tulloh, David wrote: > When in doubt benchmark, it's difficult to guess at the internal > workings of a interpretted language. I ran the attached benchmark > and found returning @foo was faster than \@foo. I have edited your function to use Benchmark, which is a more reliable way of benchmarking these sorts of things. It's results: byRef: 11755/s byValue: 7803/s Showing that the reference method is quite a bit faster. (See attached) > The difference is trivial though and I would suggest using whatever > format works best for you and then standardising on it. I personally > use return @foo because I like passing the output into list functions > like grep and map (@bar = map {} grep {} my_sub) and it's cleaner > without the @{} everywhere. I agree. I like to pass in and return arrays from things that are functional functions.. ie. they take a set of things, and return a set of things, without much state affecting them. For more complex operations I prefer to create blessed objects and accessors, which have map/filter/for style operators upon them. -Toby -------------- next part -------------- A non-text attachment was scrubbed... Name: array_return_benchmark2.pl Type: text/x-perl Size: 313 bytes Desc: not available URL: From Martin.G.Ryan at team.telstra.com Thu Feb 18 19:55:19 2010 From: Martin.G.Ryan at team.telstra.com (Ryan, Martin G) Date: Fri, 19 Feb 2010 13:55:19 +1000 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <4B7DE300.8020705@strategicdata.com.au> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> <4B7DE300.8020705@strategicdata.com.au> Message-ID: <589EE331794E0B4DA62A9ADE89BCB4057CDB2CCDFE@WSMSG3103V.srv.dir.telstra.com> Toby Corkindale suggests; > I have edited your function to use Benchmark, which is a more > reliable way of benchmarking these sorts of things. > It's results: > byRef: 11755/s > byValue: 7803/s > Showing that the reference method is quite a bit faster. > (See attached) So is the sentence or the results arse-about? ... Or am I drunk without drinking anything? Martin From toby.corkindale at strategicdata.com.au Thu Feb 18 20:08:54 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Fri, 19 Feb 2010 15:08:54 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <589EE331794E0B4DA62A9ADE89BCB4057CDB2CCDFE@WSMSG3103V.srv.dir.telstra.com> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> <4B7DE300.8020705@strategicdata.com.au> <589EE331794E0B4DA62A9ADE89BCB4057CDB2CCDFE@WSMSG3103V.srv.dir.telstra.com> Message-ID: <4B7E0ED6.5000902@strategicdata.com.au> On 19/02/10 14:55, Ryan, Martin G wrote: > Toby Corkindale suggests; > >> I have edited your function to use Benchmark, which is a more >> reliable way of benchmarking these sorts of things. > >> It's results: >> byRef: 11755/s >> byValue: 7803/s > >> Showing that the reference method is quite a bit faster. >> (See attached) > > So is the sentence or the results arse-about? > > ... Or am I drunk without drinking anything? Benchmark (in this mode) runs the code for X seconds, then reports the average number of times per second it run. So the Ref method ran more iterations-per-second, indicating it's faster. From jarich at perltraining.com.au Fri Feb 19 00:04:35 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Fri, 19 Feb 2010 19:04:35 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <20100218231620.GA27378@nipl.net> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> Message-ID: <4B7E4613.2020309@perltraining.com.au> Sam Watkins wrote: > but I normally do it like this because I feel like it should be more efficient: > > ... > return \@foo; > } > > $foo = my_func(); Yes, that is more efficient, although for small arrays, containing small data I doubt the difference in speed would matter in almost all circumstances. > This has the unfortunate effect of converting my array to an array ref. If I > wanted to reverse that, I think I could use: > > @foo = @{my_func()}; That works, but should have about the same efficiency penalty as just returning an array to start with (since all you've done is moved the copy). However if *most* of the time you want my_func to return a reference, and sometimes you want a list; this isn't a bad way to go about it. > which is getting ugly and inefficient too. The same thing happens when > returning hash variables, except that I suppose it is even more inefficient to > return it via a list return compared to a reference. For the same memory size, it *should* be the same efficiency. > My question is, does perl actually optimize this so it sucks less than I am > naively supposing it does? No, Perl doesn't optimise this. On the other hand, my question for you is why are you doing all this premature optimisation to start with? Are you actually hitting speed issues in all of your subroutines on a regular basis? I appreciate a desire to be consistent, but most of the problem this is, and should be, a non-issue. Also, is there any way to make like an alias @foo > for @$foo, so you can treat an array reference as a normal array without > writing @$foo all the time? (and also for hashes) Not in Perl 5. Yes, in Perl 6. > These concerns make me reluctant to use normal perl @array and %hash types at > all. If I have to pass and return things by reference, and can't alias these > back to normal @array and %hash types, I would prefer to use references for > everything in order to be consistent and avoid having to rewrite code when I > suddenly need to pass some variable to or from a sub. This would make the @foo > %bar syntax useless for anything but the one-liners. So I'm hoping there is > some workaround or optimization, and a way to alias them. Most real world code I see uses arrays and hashes all over the place; taking references to them when passing them into subroutines, and handling whatever the subroutine returns. Arrays and hashes are convenient, and machines are fast enough these days that programmer time and code maintaianability is usually more important. When I'm asked to help increase the efficiency of these programs, changing _all_ the data types to be references would be one of the last suggestions I'd make. I might suggest changing how some specific,larger structures were passed around, but that's about it. I'd view this advice akin to suggesting unwrapping methods to avoid calling the dispatcher. By all means use only references in your code, but be aware that it's much more a style decision (and a fairly unique one at that) than a necessary practice). J From shlomif at iglu.org.il Fri Feb 19 03:38:03 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Fri, 19 Feb 2010 13:38:03 +0200 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <4B7E4613.2020309@perltraining.com.au> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> <4B7E4613.2020309@perltraining.com.au> Message-ID: <201002191338.04228.shlomif@iglu.org.il> On Friday 19 Feb 2010 10:04:35 Jacinta Richardson wrote: > Sam Watkins wrote: > > Also, is there any way to make like an alias @foo > > > for @$foo, so you can treat an array reference as a normal array without > > writing @$foo all the time? (and also for hashes) > > Not in Perl 5. Yes, in Perl 6. > Actually, it is possible in Perl 5 - using tie: -------- CODE ------ #!/usr/bin/perl use strict; use warnings; package Tie::ArrayIndirect; use base 'Tie::Array'; sub TIEARRAY { my ($class, $ref) = @_; return bless {'ref' => $ref} , $class; } sub FETCH { my ($self, $index) = @_; return $self->{'ref'}->[$index]; } sub FETCHSIZE { my ($self) = @_; return scalar(@{$self->{'ref'}}); } sub STORE { my ($self, $index, $val) = @_; return ($self->{'ref'}->[$index] = $val); } sub EXISTS { my ($self, $index) = @_; return exists($self->{'ref'}->[$index]); } sub DELETE { my ($self, $index) = @_; return delete($self->{'ref'}->[$index]); } package main; sub return_ref { return [0,1,22,303]; } my $ref = return_ref(); my @array; tie @array, 'Tie::ArrayIndirect', $ref; print "array[2] = " . $array[2] . "\n"; push @array, 4444.4; print "ref->[4] = ", $ref->[4], "\n"; ----- END CODE ----- Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What Makes Software Apps High Quality - http://shlom.in/sw-quality Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . From alfiejohn at gmail.com Fri Feb 19 07:31:04 2010 From: alfiejohn at gmail.com (Alfie John) Date: Sat, 20 Feb 2010 02:31:04 +1100 Subject: [Melbourne-pm] returning hashes and arrays, source filters considered harmful? In-Reply-To: <201002191338.04228.shlomif@iglu.org.il> References: <20100209042517.GB8307@nipl.net> <20100218231620.GA27378@nipl.net> <4B7E4613.2020309@perltraining.com.au> <201002191338.04228.shlomif@iglu.org.il> Message-ID: Hi folks, I had to scratch that itch... I've just uploaded it to CPAN now, so it might take a while to replicate. For a sneak peak: http://h4c.kr/Scalar-Array-0.02.tar.gz Scalar::Array will turn any arrayref into an iterator by simply using the arrayref itself. Only reading is currently implemented (for now). -- 8< -- SYNOPSIS use Scalar::Array; my $rr_ref = [ 1, 2, 3, 4, 5 ]; round_robin( $rr_ref ); print sa_length( $rr_ref ); # prints 5 print $rr_ref,"\n"; # prints 1 print $rr_ref,"\n"; # prints 2 print $rr_ref,"\n"; # prints 3 print $rr_ref,"\n"; # prints 4 print $rr_ref,"\n"; # prints 5 print $rr_ref,"\n"; # prints 1 print $rr_ref,"\n"; # prints 2 print $rr_ref,"\n"; # prints 3 ... my $s_ref = [ 1, 2, 3, 4, 5 ]; shrink( $s_ref ); print sa_length( $s_ref ); # prints 5 print $s_ref,"\n"; # prints 1 print $s_ref,"\n"; # prints 2 print $s_ref,"\n"; # prints 3 print $s_ref,"\n"; # prints 4 print $s_ref,"\n"; # prints 5 print $s_ref,"\n"; # undef print $s_ref,"\n"; # undef print $s_ref,"\n"; # undef -- >8 -- I would be interested in how this benchmarks compared to the previous threads but it's now 2:30am so I'm going to bed :) Alfie On Fri, Feb 19, 2010 at 10:38 PM, Shlomi Fish wrote: > On Friday 19 Feb 2010 10:04:35 Jacinta Richardson wrote: > > Sam Watkins wrote: > > > Also, is there any way to make like an alias @foo > > > > > for @$foo, so you can treat an array reference as a normal array > without > > > writing @$foo all the time? (and also for hashes) > > > > Not in Perl 5. Yes, in Perl 6. > > > > Actually, it is possible in Perl 5 - using tie: > > -------- CODE ------ > > #!/usr/bin/perl > > use strict; > use warnings; > > package Tie::ArrayIndirect; > > use base 'Tie::Array'; > > sub TIEARRAY > { > my ($class, $ref) = @_; > > return bless {'ref' => $ref} , $class; > } > > sub FETCH > { > my ($self, $index) = @_; > return $self->{'ref'}->[$index]; > } > > sub FETCHSIZE > { > my ($self) = @_; > > return scalar(@{$self->{'ref'}}); > } > > sub STORE > { > my ($self, $index, $val) = @_; > > return ($self->{'ref'}->[$index] = $val); > } > > sub EXISTS > { > my ($self, $index) = @_; > > return exists($self->{'ref'}->[$index]); > } > > sub DELETE > { > my ($self, $index) = @_; > > return delete($self->{'ref'}->[$index]); > } > > package main; > > sub return_ref > { > return [0,1,22,303]; > } > > my $ref = return_ref(); > > my @array; > > tie @array, 'Tie::ArrayIndirect', $ref; > > print "array[2] = " . $array[2] . "\n"; > > push @array, 4444.4; > > print "ref->[4] = ", $ref->[4], "\n"; > > ----- END CODE ----- > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > What Makes Software Apps High Quality - http://shlom.in/sw-quality > > Deletionists delete Wikipedia articles that they consider lame. > Chuck Norris deletes deletionists whom he considers lame. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > _______________________________________________ > 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 jarich at perltraining.com.au Sun Feb 21 14:55:01 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 22 Feb 2010 09:55:01 +1100 Subject: [Melbourne-pm] Programming Perl course, next week (1st - 5th March), $1000 discount Message-ID: <4B81B9C5.9050909@perltraining.com.au> G'day folk, We're running a Programming Perl course in Melbourne next week, Monday 1st - Friday 5th at: Saxons Level 8 500 Collins Street Melbourne VIC 3000 and I'd really like to have a few more people on it. As such I'm offering Melbourne Perl Mongers, and their colleagues, a $1000 discount on the training course if you sign up before noon on Wednesday (and mention this email). The course is lots of fun, and I hope to see a booking from you soon! http://perltraining.com.au/bookings/Melbourne.html All the best, Jacinta -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From jarich at perltraining.com.au Sun Feb 21 21:55:47 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 22 Feb 2010 16:55:47 +1100 Subject: [Melbourne-pm] Apache re-write help Message-ID: <4B821C63.3000908@perltraining.com.au> G'day folk, I don't have much experience with Apache, but I need to rewrite some URLs. At the moment I have url like: http://some.example.com/documents/features?title=some+title&venue=some+venue The problem is that all statistics for this hit, and for all other titles/venues are all assigned to the features page (obviously). What I would like to do is change the code to generate something like: http://some.example.com/documents/features/some+title/some+venue and then Rewrite it back into the GET request so that the server still calls the correct script (there's more than one) with the correct arguments. It seems intuitively correct that this will then result in hits to these pages being counted separately. I think what I need is to add this to my .htaccess file RewriteEngine on RewriteRule ^features/([^/]+)/([^/])+/?$ features?title=$1&venue=$2 [L] Does that seem sane? Or have I misunderstood how this should work? Thanks, J From scottp at dd.com.au Sun Feb 21 22:49:26 2010 From: scottp at dd.com.au (scottp at dd.com.au) Date: Mon, 22 Feb 2010 00:49:26 -0600 (CST) Subject: [Melbourne-pm] Apache re-write help In-Reply-To: <1710803067.52551266821308133.JavaMail.root@mail-4.01.com> Message-ID: <2090439889.52601266821366542.JavaMail.root@mail-4.01.com> Unfortunately not. ModRewrite will only rewrite URLs, not query strings. But it is not hard to write one that can in ModPerl. Or... you can even write a CGI that receives "features" that returns a move. If you need some stub I can whip one up. Scott ----- "Jacinta Richardson" wrote: > G'day folk, > > I don't have much experience with Apache, but I need to rewrite some > URLs. At > the moment I have url like: > > http://some.example.com/documents/features?title=some+title&venue=some+venue > > The problem is that all statistics for this hit, and for all other > titles/venues > are all assigned to the features page (obviously). What I would like > to do is > change the code to generate something like: > > http://some.example.com/documents/features/some+title/some+venue > > and then Rewrite it back into the GET request so that the server still > calls the > correct script (there's more than one) with the correct arguments. It > seems > intuitively correct that this will then result in hits to these pages > being > counted separately. > > I think what I need is to add this to my .htaccess file > > RewriteEngine on > RewriteRule ^features/([^/]+)/([^/])+/?$ features?title=$1&venue=$2 > [L] > > Does that seem sane? Or have I misunderstood how this should work? > > Thanks, > > J > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm -- http://scott.dd.com.au/ scottp at dd.com.au From rob at cataclysm.cx Mon Feb 22 01:07:03 2010 From: rob at cataclysm.cx (Robert Norris) Date: Mon, 22 Feb 2010 20:07:03 +1100 Subject: [Melbourne-pm] Apache re-write help In-Reply-To: <4B821C63.3000908@perltraining.com.au> References: <4B821C63.3000908@perltraining.com.au> Message-ID: <20100222090703.GA490@junai.home> > I think what I need is to add this to my .htaccess file > > RewriteEngine on > RewriteRule ^features/([^/]+)/([^/])+/?$ features?title=$1&venue=$2 [L] Slightly broken regex there (the repetition operator should come inside the capture), but I think that looks about right. You should also add the [QSA] (query string append) flag to make sure that, well, the query string gets appended :P I'm no mod_rewrite expert by any stretch, but I have done almost exactly what you're doing many times when setting up MediaWiki to have pretty URLs. Its normal to do something like this: RewriteRule ^(.*)$ wiki/index.php?title=$1 [L,QSA] Cheers, Rob. From scottp at dd.com.au Mon Feb 22 01:18:04 2010 From: scottp at dd.com.au (Scott Penrose) Date: Mon, 22 Feb 2010 20:18:04 +1100 Subject: [Melbourne-pm] Apache re-write help In-Reply-To: <20100222090703.GA490@junai.home> References: <4B821C63.3000908@perltraining.com.au> <20100222090703.GA490@junai.home> Message-ID: On 22/02/2010, at 8:07 PM, Robert Norris wrote: >> I think what I need is to add this to my .htaccess file >> >> RewriteEngine on >> RewriteRule ^features/([^/]+)/([^/])+/?$ features?title=$1&venue=$2 [L] > > Slightly broken regex there (the repetition operator should come inside > the capture), but I think that looks about right. You should also add > the [QSA] (query string append) flag to make sure that, well, the query > string gets appended :P It won't rewrite the query string, just append it. > RewriteRule ^(.*)$ wiki/index.php?title=$1 [L,QSA] Yes that way round is fine, but you can't do a regex on the left. I.e. you can add a query string of the data on the right. Scott From jarich at perltraining.com.au Mon Feb 22 03:41:24 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 22 Feb 2010 22:41:24 +1100 Subject: [Melbourne-pm] Apache re-write help In-Reply-To: References: <4B821C63.3000908@perltraining.com.au> <20100222090703.GA490@junai.home> Message-ID: <4B826D64.7090009@perltraining.com.au> Scott Penrose wrote: >>> RewriteEngine on >>> RewriteRule ^features/([^/]+)/([^/])+/?$ features?title=$1&venue=$2 [L] >> Slightly broken regex there (the repetition operator should come inside >> the capture), but I think that looks about right. You should also add >> the [QSA] (query string append) flag to make sure that, well, the query >> string gets appended :P > > It won't rewrite the query string, just append it. I think that's fine. I'm talking about changing my code so that it has sane looking urls, and then rewriting those to query strings. >> RewriteRule ^(.*)$ wiki/index.php?title=$1 [L,QSA] > > Yes that way round is fine, but you can't do a regex on the left. I.e. you can add a query string of the data on the right. Yup, I want sane url to be generated by my code, and then to turn that into a query string just for the server (such that the client never need know what they're dealing with underneath. Thanks Robert and Scott. J From pat at patspam.com Sat Feb 27 16:29:00 2010 From: pat at patspam.com (Patrick Donelan) Date: Sat, 27 Feb 2010 19:29:00 -0500 Subject: [Melbourne-pm] No, really.. In-Reply-To: <4B6A4758.2090303@strategicdata.com.au> References: <4B6A3852.9040202@strategicdata.com.au> <42321ee21002031957s22c091c6tf2dee03ac9b93a17@mail.gmail.com> <4B6A4758.2090303@strategicdata.com.au> Message-ID: <42321ee21002271629x5a271036u317c00efcbf13387@mail.gmail.com> > > try "cpanp i Task::Kensho" and let me know how you go? :) > > How about App::cpanminus? Installing Task:: modules without the --interactive option will proceed with the default answer to every question, which might be a step towards what you want? Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: