my @arr = (" This has a leading space", "This does not" );

foreach my $string (@arr ) {
   $string =~ s/^\s//;
   print $string, "\n";
}

prints:
This has a leading space
This does not

The regular expression
s/^\s//;
means
s/          # substitute
^           # at the beginning of the string
\s          # one space character ( space, tab, or newline )
/           # and replace it with
/           #nothing
;


----- Original Message ----- 
From: "Susan Aurand" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 1:08 PM
Subject: strip first space


> If I have a string and the first character is a space,
> may not always be a space.
> Example:  John
>               Tommy
>                 Beth
> 
> John and Beth have a space, Tommy does not.
> How do I strip that. I do not want to use the global
> command because a want the space between First
> and Last name. Any suggestions?
> 
> Susan
> Information Technology Center
> 828-627-8314
> 
> 
> -- 
> 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