On Wednesday, May 15, 2002, at 01:35 , Hanson, Robert wrote:
> What is the error?
>
> Rob
I agree with rob - the error message would help.
[..]
> I am trying to write a package that will execute a sql statement for me in
> my cgi pages, the following is the code for the package, but when I run it
> at the command prompt I get error messages about the first line where I
> set
> the $dsn. I think the problem is with the use of DBI. The sql that I pass
> to this package does not get executed. I call the package on my cgi page
> with:
>
> $s = GetRecords->Execute_SQL($sql);
I fear I know the problem here.....
I am not sure we are talking 'package' in the same sense
#!/usr/bin/perl -w
use strict;
my ($spot, $dog, $colour) = qw/dog big brown/;
print "had $spot, $dog, $colour\n";
$colour = JoeBob->doBob($spot, $dog);
print "\ngot $spot, $dog, $colour\n";
package JoeBob;
sub doBob {
my ($val, $friend ) = @_;
print "SUB: $val => $friend" ;
my $retval = "$friend :: $val";
$retval;
} # end of doBob
will generate
had dog, big, brown
SUB: JoeBob => dog
# got dog, big, dog :: JoeBob
but if I modify the package Call to
$colour = JoeBob::doBob($spot, $dog);
we get the expected results....
The problem seems to be that you are playing fast and
loose with the syntax of using an annonymous object -
with out all the Religion of bless it appropriately ....
hence if you REALLY want it to be
$colour = JoeBob->doBob($spot, $dog);
then you have to be selfless in your assignment in the sub:
sub doBob {
my ($self, $val, $friend ) = @_;
print "SUB: $val => $friend" ;
my $retval = "$friend :: $val";
$retval;
} # end of doBob
cf:
http://www.wetware.com/drieux/pbl/bloopers/pkgFumbles.txt
May I recommend to you:
http://www.wetware.com/drieux/CS/lang/Perl/PM/
perchance you can also critique
http://www.wetware.com/drieux/CS/lang/Perl/PM/OO_v_Procedural.html
from which I have two different samples of the same module -
one implemented in OO....
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]