Gerald...
Thanks for getting back so quickly,
The FINANCEMOD.pm seems to have a correcly built constructor. I tried
to spare the list of
some of the details, but let me just display this snipet...
package FINANCEMOD;
use SQLHANDLE;
sub new {
my $pkg = shift;
my $fdatref = shift;
my $database = 'patients';
my $obj = bless {
'_fdatref' => $fdatref,
'_balances' => 0, ## array ref for balances
'_prev_patnums' => 0, ## array ref for prev_patnums
'_dbh' => SQLHANDLE->allocate($database)
}, $pkg;
return $obj;
}
______________________________________________________________________________________________
package SQLHANDLE; #BASE CLASS
use DBI;
@ISA = qw(DBI);
sub allocate{
my($pkg) = shift;
my($database) = shift;
my $r_statement = bless {
'_fetch_method' => 'fetchall_arrayref',
'_statement' => 0,
'_records' => 0,
'_database' => $database,
'_dbh' => SQLHANDLE::getdbh($database),
}, $pkg;
return $r_statement;
}
sub getdbh{
my $database= undef;
my $objref = shift;
if( ref($objref) ){
return $objref->{_dbh};
}
$database = $objref;
if (!$database){
die "$! $database\n";
}
my $dbh = DBI->connect("DBI:mysql:$database:localhost",
"root","let.me.in") or die "$!";
return $dbh;
}
_________________________________________________________________________________________________________
We run into this trouble when people hit the back button. When trying
to track down the bug, I added a
stich of code to foreach through the fdat hash. Then the problems
seemed to go away...though we are testing
it currently. It might be that the fdat array is not being sent,
destroying the objects ability to be
defined correctly.
Gerald Richter wrote:
>
> > I seem to randomly loose my objects from the EMBPERL pages.
> >
> > For example we have one page from the database called with the
> > following code:
> >
> >
> > 1 [- use FINANCEMOD;
> > 2 $obj = FINANCEMOD->new(\%fdat) -]
> > 3
> >
> > 12 [- $head = $obj->page_head(); -]
> >
> > I get the following error:
> >
> > Can't call method "page_head" without a package or object
> > reference at somegirls line 12.
> >
>
> looks like your new returns undef or at least not an object reference
___________________________________________________________________________________
>
> > If we don't include the semicolon after the use statement, the module
> > fails to be called into the program at all.
> >
>
> That doesn't wonder. You always need a semicolon to speparte two Perl
> statements, that nothing special about Embperl
:)
Yes. In order to spare you too much code, I forgot to mention that we
have rewritten the
code to be
[- use FINANCEMOD -]
and this fails to take in the module. It ends with a return 1
statement.
I run into this often.
>
> >
> > What is the best way to make sure use works in a page?
> >
>
> use had worked. If not you have seen an error message about "FINANCEMOD"
> >
> > I'm very confused about how the scoping works. It looks like a bug in
> > EMBPERL.
>
> I don't think so
>
> > The documentation on the scoping is also confusing
> > What exactly is the difference between [- -] and [* *]?
> >
>
> >From point of scoping [- -] is wrapped in an Perl { } block,
Does that mean the entire pages embperl is evaluated together as one
eval?
We call a CGI from modules from EMBPERL all under mod_perl. When we run
into
this bug, it seems to happen after [$ $] if or whiles or foreaches.
I've also wondered
about $escmod - it might be adding to the trouble as we are changing it
from section to selection.
while [* *]
> isn't, but this nothing todo with your problem. Your Embperl code is
> correct, but something inside your new seems to went wrong.
>
> Gerald
>
> -------------------------------------------------------------
> Gerald Richter ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
>
> Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
> E-Mail: [EMAIL PROTECTED] Voice: +49 6133 925151
> WWW: http://www.ecos.de Fax: +49 6133 925152
> -------------------------------------------------------------
--
Ruben I Safir
[EMAIL PROTECTED]
http://www.brooklynonline.com
Manager of Intranet Development NYU College of Dentistry
Resume: http://www.wynn.com/jewish/resume.html
Perl Notes:
http://www.wynn.com/jewish/perl_course