|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Passing a $dbh to a subroutine
Date: Sep 18 1997 9:00PM
Jamie Thingelstad wrote:
>
> Michael Peppler stated:
> #
> # Yes, absolutely:
> #
> # my $dbh = new Sybase::DBlib;
> #
> # do_insert($dbh);
> #
> # sub do_insert {
> # my $dbh = shift;
> #
> # $dbh->dbcmd(...);
> # $dbh->dbsqlexec; $dbh->dbresults;
> # }
> #
>
> Is there a difference between:
>
> my $dbh = new Sybase::DBlib;
>
> mySub($dbh);
>
> sub mySub ($) {
> ...
> }
>
> and:
>
> my $dbh = new Sybase::DBlib;
>
> mySub(\$dbh);
>
> sub mySub (\$) {
> ...
> }
>
> does pass by reference matter with this?
Well the $dbh is already a reference, so taking a reference to it
is OK, but then you'd have to dereference it in the subs.
You only need to pass things by reference if they aren't already
references and you need to modify the original values...
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
|