Learn Perl <[EMAIL PROTECTED]> wrote:
> 
> 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.
>

There are several reasonable answers, and I'm not
sure which one you're looking for:

 1) tr/ //d      # remove all *spaces*
 2) s/\s+//g     # remove all "whitespace"

And check:

  $ perldoc -q 'blank space'

For how to trim leading/trailing whitespace.

And fyi, chomp() removes $\, the input record
separator, which is a newline by default, gets
changed fairly often. 

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

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

Reply via email to