[prev in list] [next in list] [prev in thread] [next in thread]
List: cgiapp
Subject: Re: Apache::DBI and CGI::Application with lots of modules.
From: Eric Frazier <ef () kwinternet ! com>
Date: 2002-10-15 11:15:49
[Download RAW message or body]
Hi,
I had to read that over a few times to get it. And now I see that I do
indeed have that situation, there are a number of times when I call
my $holdstatus = new Holds(); from within a module that also has a new
method. What I don't understand is how does my code work at all?
Thanks,
Eric
At 07:13 PM 10/14/02 +0200, Rafiq Ismail wrote:
>On Mon, 14 Oct 2002, Eric Frazier wrote:
>> >That looks like voodoo code copied from a man page. If you call this as
>> >Holds->new(), you don't need that junk about ref. (And most people
>> >recommend against the "new Holds" syntax.)
>>
>> I wanted the DBH to be global since just about every sub in Holds does a
>> query of some sort. I guess it doesn't matter either way if I do the connect
>> in the new() vs up top outside of a sub.
>
>Boredom break:
>
>As for your dbh, stick it whereever its scope applies, however I don't
>like declaring globals, so I've found that if I make the dbh accessible
>via an object, usually together with Apache::DBI in the background, I can
>often do clean up stuff, such as closing the handle (incase Apache::DBI
>isn't in place with a particular invokation of the package), last system
>logging updates/inserts, or whatever the job requires in a DESTROY method.
>
>> What is the problem with the my $holdcheck = new Holds() type of syntax?
>> I never read anything about that either way.
>It's in the book which I think should be called, 'the guy in the silly hat
>book,' ie. Damien's OO book, pretty much saying that,
>
>"The indirect object syntax does, however, suffer from the same type of
>ambiguity problems that sometime befuddles print ....
>
> my $cd3 = new get_classname() (@data) #Compilation Error
>
>...
>
> <parapharased type="badly">
> Assuming you have $cd="MyPackage" and:
> get_name $cd;
>
> This is usually equivalent to:
> $cd->get_name;
>
> However, let's say that you have a method in the invoking script
>named 'get_name', then:
>
> get_name $cd;
>
> Gets interpreted as:
>
> get_name("MyPackage")
>
> Which is not what you're after.
> </paraphrase>
>" - from the guy in the silly hat book
>
>--
>Senior Programmer
>Bookings.nl
>----------------------------------------------------------
>Me::rafiq@dreamthought.com||www.dreamthought.com
>Budget hosting on my 10Mbit/backbone::info@dreamthought.com
>
>
(250) 655 - 9513 (PST Time Zone)
"Inquiry is fatal to certainty." -- Will Durant
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic