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.
Any help appreciated thanks in advance.
There are a couple ways to do this. In this case, I would probably:
@names = split /\s*,\s*/, $contact;
which removes the spaces as part of the split operation.
The reason your tr command failed is that you must specify the d flag:
$names[1] =~ tr/\s//d;
if you want to delete characters.
Regards, Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>