passing by value vs. passing by reference

2006-07-04 Thread Jhst463
I have a subroutine that, amongst other things, chops a scalar variable, $dir, passed to it as an argument. The problem is that I need $dir intact (ie unchopped) after calling said subroutine, but it has been altered by the chop. I can't figure out how to pass the value (or more precisely, a

Re: passing by value vs. passing by reference

2006-07-04 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: I have a subroutine that, amongst other things, chops a scalar variable, $dir, passed to it as an argument. The problem is that I need $dir intact (ie unchopped) after calling said subroutine, but it has been altered by the chop. I can't figure out how to pass

Re: passing by value vs. passing by reference

2006-07-04 Thread Aaron Priven
You should show us some code. Normally you would do this in the subroutine: sub routine { my $mydir = shift; # which puts the value of $_[0] into $mydir # and then removes that from the argument list chop $mydir; # do stuff with $mydir } That makes a copy of the value. It

Re: passing by value vs. passing by reference

2006-07-04 Thread Aaron Priven
On Jul 4, 2006, at 10:46 AM, Aaron Priven wrote: you could pass it an expression that returns the value of $a. Sorry, I should have said your variable instead of $a here. -- Aaron Priven, [EMAIL PROTECTED], http://www.priven.com/aaron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: passing by value vs. passing by reference

2006-07-04 Thread Mr. Shawn H. Corey
Aaron Priven wrote: You should show us some code. Normally you would do this in the subroutine: sub routine { my $mydir = shift; # which puts the value of $_[0] into $mydir # and then removes that from the argument list chop $mydir; # do stuff with $mydir } That

Re: passing by value vs. passing by reference

2006-07-04 Thread D. Bolliger
[EMAIL PROTECTED] am Dienstag, 4. Juli 2006 19:17: I have a subroutine that, amongst other things, chops a scalar variable, $dir, passed to it as an argument. The problem is that I need $dir intact (ie unchopped) after calling said subroutine, but it has been altered by the chop. I can't