[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 the value (or more precisely, a copy of the 
> value) of $dir to subroutine so that it's operations do not alter what $dir 
> originally contained.  I've read Mr. Wall's Camelbook and saw lots of info on 
> hard, 
> soft, and symbolic references, but nothing (that I could understand) about 
> passing a copy of variable to a subroutine and not the variable itself.
> 

Create a temporary variable for it:

{
  my $tmp = $dir;
  chop $tmp;
  my_sub( $tmp );
}



-- 
__END__

Just my 0.00000002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by
doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to