$str = " a_ string  ";
$str =~ s/\s+//g;
print $str;

btw. chomp() removes the character defined by $/ (newline unless you change
it) from the end of a string.
     chop()  removes the last character from a string.

> -----Original Message-----
> From: learn perl [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 15, 2002 9:38 AM
> To: [EMAIL PROTECTED]
> Subject: deleting spaces
> 
> 
> Hi guys,
> 
> I have a simple question.
> 
> Is there ways to get rid of any spaces within a variable?
> 
> say the variable holds " R" or "R " or " R ".
> is there a function I could use for that?
> I tried chomp but it will only get rid of the last space but not the
> leading spaces.
> 
> Thanks
> 
> Eric
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to