PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

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