Had a good play around with Class::Phrasebook and Log::LogLite today. As a consequence I've re-evaluated my Devel::Trace module and now use Log::LogLite to handle all the file accessing. Will have to change the log template though, as it looks a bit messy.
Class::Phrasebook now holds all my SQL statements and makes life alot easier. I wish I'd know about this while at QIIS, the intranet was littered with SQL all over the place. One of the reasons it needs a big evaluation of the database.
Had a quick look at Regexp::Common, and may start using that too. Though from the docs it looks like there is limited support for UK codes. Might see if I can write a patch for some of the missing items. Mind you thats always assuming I get time.
I've ended up learning quite a few modules over the last year. Thanks in part to Mark's Perl Advent Calendar. I'm slowly looking up modules Acme has mention in various talks. I keep finding lists of modules that I really ought to take a look at, from notes taken at various talks over the last couple of years. I've made some headway, but CPAN is BIIIIIG :)
I have finally started to take a look at Damian Conway's book on Object Orientated Programming. Though with the way my free time is going at the moment, I might finish it before Christmas. My initial observations are really good. Like his talks, Damian knows just the right way to demystify the confusing, and explain things so you end up saying "Ah right. Now why didn't anyone explain it like that before?". I promised London.pm I'd send them a review back last year. Thankfully I didn't say when I'd submit it ;) Hopefully this year though.
Class::Phrasebook now holds all my SQL statements and makes life alot easier. I wish I'd know about this while at QIIS, the intranet was littered with SQL all over the place. One of the reasons it needs a big evaluation of the database.
Did you end up finding a solution for using placeholders versus interpolated statements with Class::PHrasebook? After reading the perl.com article and reading the docs, I didn't see anything obvious.
Re:Placeholders?
barbie on 2003-04-06T23:12:37
It depends how you are using them. In the majority of cases I've been letting the DBD driver/database handle the placeholders. However, there are a few SQL statements that lend themselves to letting Class::Phrasebook handle them.For example I have a standard look up of all items in a table, "SELECT * FROM $table", the phrase is named "lookup". Another search allows for multi-column ordering (ascending and descending), and again I just add the columns in order depending on what the user selects.
I've tried to rely on the database as much as possible, as that makes the code neater, which has been the aim of using Class::Phrasebook for me
:) Re:Placeholders?
djberg96 on 2003-04-07T15:35:31
No, I mean "SELECT * FROM $table" is not the same as "SELECT * FROM ?". The former is going to create a new execution plan every time you run it, the latter does not.Mind you, if you only run the query once, it makes no difference. I'm just wondering how you deal with and unnamed placeholder (i.e. "?"), if at all.
Am I making sense?
Re:Placeholders?
barbie on 2003-04-11T08:48:48
I tend to use unnamed placeholders purely for statements that are likely to be prepared once and executed many times, and use named for statements I tend to execute once only.My primary goal is to make the code readable. In some phrases I mix and match between named and unnamed, and in cases where there are several optional values in an UPDATE statement, I use Class::Phrasebook::SQL to handle any undefined named values. I try and let the DBI do as much of the work as possible, so I can rely on caching. Particluarly once I start running under mod_perl.
Is that the kind of thing you were after?
Re:Placeholders?
djberg96 on 2003-04-11T23:30:31
I'm confused about how you would use placeholders and Class::Phrasebook::SQL together. Do you have an example you could share?
In fact, today, I've written my first class that uses blessed coderefs. Damn that's a neat idea!
-Dom
There were a couple of lengthy discussions about UK post code regexps on the london.pm mailing list last week. Since they were over a couple of separate threads, it's probably best if you start at the mailing list archive index and browse from there.
N
Re:UK post codes
barbie on 2003-04-07T08:47:11
I'm already a London.pm'er:) I rewrote the Netscape javascript validation file a few years ago, for UK postcodes and telephone numbers, among other things, so already have a couple of regexs ready.
I did read with interest the thread on postcodes, as I'd already got m/[a-z]{1,2}\d{1,2}[a-z]?\s+\d{1,2}[a-z]{1,2}/i for the cases I knew about, and we certainly haven't had any problems from clients. I think the thread highlighted a couple of expections that break my version, so will probably rework it to fit those in
:)