my $str = "Bob "; $str =~ s/\s$//; # or s/ $//; print "|$str|\n";