Thanks everyone for your help, I found the problem was with (1) my 
understanding of how Perl functions act on variables in general and (2) with 
how chop in 
particular behaved.

My subroutine originally contained this:

sub xyz {
    $x = chop $_[0];
    ... do stuff with $x
}

which demonstrates both my misperceptions.

(1) I was thinking that Perl functions were pass by value, i.e. I thought 
$_[0] would not be altered.  In other words, I was thinking object-orientedly 
or 
more precisely, I was using Java's String class and it's methods to understand 
how Perl operated on scalars.  In Java, Strings are immutable and any method 
that alters the content of a String actually returns a new String object 
composed of the alterations on the original, which remains intact.

(2) I thought chop returned $_[0] minus the last char, when in fact it only 
returned the last char.

Anyways, this how my subroutine now looks:

sub xyz {
    $x = $_[0];
    chop $x;
    ... do stuff with $x
}

thanks again,
[EMAIL PROTECTED]

P.S.
It was chop and not chomp that I need, I'm removing the last "/" on a 
directory path, not newlines

-- 
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