-----Original Message----- >From: howa <[EMAIL PROTECTED]> >Sent: Nov 3, 2007 10:13 AM >To: beginners@perl.org >Subject: Re: Is Perl object passed by reference automatically in function call? > >On 11 2 , 8 58 , [EMAIL PROTECTED] (Chas. Owens) wrote: >> On 1 Nov 2007 15:36:09 -0700, howa <[EMAIL PROTECTED]> wrote:> So if I have >> an object, I don't have to pass its reference to function >> > for performance gain? >> >> > is that true? >> >> snip >> >> Objects are only stored as references, so yes, when you pass one to a >> function, it is by reference. > >Thanks. > >So is my understanding correct? > >Passing parameters (in or return) during function calls: > >Pass by reference can improve performance: Array (List) , Scalar >Pass by reference can't improve performance: Hash, Object, Reference > >Is that true? > >
Not correct. We generally pass or return a reference of hash,array,file/dir handle to or from a subroutine. We can only pass or return an object by its reference. Reference is also a scalar, when passing or returning a scalar, you don't need to use its reference. Passing or returning the scalar itself is good enough. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/