but i think the second call to MyDB->dbh is independent to the first one and like a new instance of something.
New instance of what? $DBH? no.
{ package Cow; my $i; sub moo { print(("moo " x ++$i), "\n"); } } Cow->moo(); # moo Cow->moo(); # moo moo Cow->moo(); # moo moo moo
{ package MyDB; my $DBH; sub dbh { if ($DBH) { print "found existing $DBH\n"; } else { $DBH = 'dbh'; print "Init $DBH\n"; } } } MyDB->dbh(); # Init dbh MyDB->dbh(); # Found existing dbh MyDB->dbh(); # Found existing dbh
In reply to Re^3: OO question
by ikegami
in thread OO question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |