From Clive.darke at qa.com Tue Apr 4 03:44:33 2006 From: Clive.darke at qa.com (Darke, Clive) Date: Tue, 4 Apr 2006 11:44:33 +0100 Subject: [DCPM] Inside-out object accessor Message-ID: <5EEF6C3D-5F12-441A-9918-D620BD6766BD@mimectl> Anyone using inside-out objects? Arguments for or against the following generic accessor would be very welcome! Aside from the usual eval/evil argument, that is. It just seems too simple to be true. $self is the reference $attr is the name of the attribute, and the name of the attribute hash $value is the value to be set sub set { my ($self, $attr, $value) = @_; my $key = refaddr $self; my $hashref; eval "\$hashref = \\\%$attr"; if ( !defined $hashref ) { carp 'Invalid attribute name'; } else { $hashref->{$key} = $value; } } A 'get' accessor could be similar. Clive ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/devoncornwall-pm/attachments/20060404/d578ec32/attachment.html From steve at devon-it.co.uk Tue Apr 4 03:50:07 2006 From: steve at devon-it.co.uk (Steve Marvell) Date: Tue, 4 Apr 2006 11:50:07 +0100 Subject: [DCPM] Inside-out object accessor In-Reply-To: <5EEF6C3D-5F12-441A-9918-D620BD6766BD@mimectl> References: <5EEF6C3D-5F12-441A-9918-D620BD6766BD@mimectl> Message-ID: <20060404105007.GA6673@devon-it.co.uk> Darke, Clive wrote: > sub set { > my ($self, $attr, $value) = @_; > my $key = refaddr $self; > my $hashref; > eval "\$hashref = \\\%$attr"; > > if ( !defined $hashref ) { > carp 'Invalid attribute name'; > } > else { > $hashref->{$key} = $value; > } > } You're going to have to explain tht a bit more for me before I understand why it's good :) Steve From Clive.darke at qa.com Tue Apr 4 04:06:17 2006 From: Clive.darke at qa.com (Darke, Clive) Date: Tue, 4 Apr 2006 12:06:17 +0100 Subject: [DCPM] Inside-out object accessor In-Reply-To: <20060404105007.GA6673@devon-it.co.uk> Message-ID: > You're going to have to explain tht a bit more for me before I understand why it's good :) OK. The basis of inside out objects is that the attributes are held in lexical hashes, one per attribute. For example %name, %address, etc. The key to the hash is a stringified reference - any old reference so long as its unique. This reference is used as the blessed object. Normally I would create a get or set type subroutine for each attribute, get_name(), set_name(), get_address(), set_address(), etc. This can be a lot of tedious code to maintain. However this accessor covers any number of attribute hashes. It seems so simple to me that I just know there must be a drawback, though I can't see one (except that it might need a truck load of comments). Clive ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/devoncornwall-pm/attachments/20060404/56f979c2/attachment.html From aaron.trevena at gmail.com Fri Apr 14 02:48:22 2006 From: aaron.trevena at gmail.com (Aaron Trevena) Date: Fri, 14 Apr 2006 10:48:22 +0100 Subject: [DCPM] Maypole 2.11 developer release / pre-release on cpan Message-ID: Hello you lot, You might be interested to know that you can get a funky new Maypole 2.11 beta from cpan. Known issues are in rt.cpan.org, but the only real one at the moment is get arguments when using mod_perl2 without libapreq2, which will be fixed before the final release. I'm hoping we'll get some good feedback from this release, and that it can be used until the real 2.11 is rock solid and ready to go live. You'll see a lot of improvements over older versions of maypole and hopefully get an idea of the direction that myself and peter speltz want to take it into - namely a well integrated MVC application server using CDBI and TT. The next release will be focussing on performance and much better form handling using Data::FormValidator (but backwards compatible with earlier releases that use CGI::Untaint). cheers, A. From simon at technocool.net Tue Apr 18 03:16:32 2006 From: simon at technocool.net (Simon Waters) Date: Tue, 18 Apr 2006 11:16:32 +0100 Subject: [DCPM] DBI connect error message oddity - Postgres Message-ID: <4444BC80.70602@technocool.net> We have some tried and trusted perl scripts. But I noticed when the database server is down the error message is "mangled". Reproducing snippit. --------------- #!/usr/bin/perl use strict; use warnings; use DBI; my $dbh=DBI->connect("dbi:Pg:dbname=dbname;host='mercury';port=5432", "dbuser","dbpass"); ---------------- Assuming "mercury" is a host refusing connections. ./fail.pl DBI connect('dbname=dbname;host='mercury';port=5432','dbuser',...) failed: could not connect to server:lT @?z@ Is the server running on host "mercury" and accepting TCP/IP connections on port 5432? at ./fail.pl line 6 Whats the "lT @?z@" bit? I tried setting some locale settings, but before I dig away at this, anyone going to leap up and say it is; "UTF8", "Unicode", bad DSN syntax, or other stupidity on my part. Debian Sarge, and DBI packages from Sarge as well. I don't recall this error when it was Redhat, but you know you kind of don't pay much attention to "database connect errors" when you are busy fixing the database server. But I just know if I ignore this any longer, some day it will report something vital in a mangled form much like this one. From aaron.trevena at gmail.com Fri Apr 21 02:47:52 2006 From: aaron.trevena at gmail.com (Aaron Trevena) Date: Fri, 21 Apr 2006 10:47:52 +0100 Subject: [DCPM] Venue for Perl Mongers Technical Meeting 17th May Message-ID: Hi all, We've been trying to find a good pub or bar with food and a private space for the Perl Mongers Technical Meeting on the 17th of May. We're after a nice pub, or restaurant or bar with space for a couple of dozen people to watch some talks, eat, drink and chat without loud/distracting music/footy/etc, preferably in the Barbican area, or near the station. Any help would be much appreciated. Many thanks, Aaron