my $ws = '[\s\0xA0]'; # white space $data =~ s/^$ws+|$ws+$//g;