On Wednesday 19 May 2004 05:25 pm, Michael Robeson wrote:
> Sorry, I meant to upload this script (see below). However, I have one
> last question. Why can't I use
>
> s/\n//g; # instead of
>
> tr/A-Za-z-//cd;
>
>
>
> in the script below? I thought it would be simpler to remove the
> newline characters from $_ which is all I really want to do. However,
> most of the time all I will see are "-" and letters which is why I set
> the tr function the way I did.
Hi Mike,
I'm not sure if I understand exactly what you want to do here, but if you want
to remove trailing newlines only, I'd use
chomp;
>
> I just couldn't figure out why the substitution function wouldn't work
> in this case. How am I setting it up wrong?
Just guessing - could it be that you need to assign the return value of s///?
Something like
my $var_without_newlines = s/\n//g;
?
HTH,
Philipp
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>