On Feb 12, David Inglis said:

>Can anybody tell me what I'm doing wrong I have a variable with a value
>"bloggs, joe" which I then spilt into 2 using @names=split(/\,/, $contact)
>I then have $names[1] with a space at the front,  I have tried to remove
>it by doing  $name[1]=~tr/\s//; but it does not remove the leading space.

tr/// does not recognize regex notations.  You'd need to say

  $names[1] =~ tr/\n\r\t\f //d;

You're also missing the 'd' modifier to tr///, which specifies to delete
characters on the left side that aren't given replacements on the right.

But you might just want to do

  $names[1] =~ s/\s+//g;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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