|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re: PerlOO what i am doing???by tobyink (Canon) |
| on Aug 12, 2012 at 07:08 UTC ( [id://986938]=note: print w/replies, xml ) | Need Help?? |
|
You are not currently doing object-oriented programming. You are doing something that might superficially resemble OOP, but it's not OOP. If you want to do OOP in Perl, I'd strongly suggest Moose or one of its friends (Mouse, Moo or Mo). These toolkits hide away much of the boilerplate code associated with Perl OOP, and allow you to concentrate on the business of writing and using your classes. OOP aside, I'd say that your biggest problem though is the fact that you're not using DBI's prepared statements properly. Don't do this:
Do this (thanks Anonymous Monk below for the correction):
This allows DBI to handle escaping issues for you, and in many cases optimize multiple calls of execute. Anyhow, here's my rewrite of your package using Moose and prepared statements...
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||