l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 7: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2001 Dec 30 17:04

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] A question of perl style
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] A question of perl style


  • Subject: [vox-tech] A question of perl style
  • From: Jay Strauss <jjstrauss@yahoMAPSo.com>
  • Date: Mon, 30 Apr 2001 11:01:38 -0700

Lets say I have a database handle object, $dbh.  Now I
want to pass it to another subroutine like:

backup(dbh=>$dbh);

sub backup
{
   my (%arg) = @_;
   my $sth = $arg{"dbh"}->prepare(some SQL);
   my $rc  = $sth->execute();
}

Now this works, but shouldn't I be passing a reference
to the object, and then unreferencing it in the sub
routine?

I tried:

backup (dbh=>\$dbh);

sub backup
{
   my (%arg) = @_;
   my $dbh = \$arg{"dbh"};
   my $sth = $dbh->prepare(some SQL);
   my $rc  = $sth->execute();
}

But that didn't work.  Maybe this is all stupid
because I think $dbh is just a pointer to an object,
and so passing by value just gives me another pointer
to an object.

Jay


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.