On May 18, David Merrill said:

>$title =~ s/\s*$//;
>
>where $title = "The Linux Programmer's Guide         "
>
>and it is being truncated after the ' mark. All I want to do is remove
>the trailing spaces from the string. Can someone please help?

You've already solved your problem about single quotes, but here's
something you might want to change:

>-- 
>Dr. David C. Merrill                     http://www.lupercalia.net
>Linux Documentation Project                   [EMAIL PROTECTED]
>Collection Editor & Coordinator            http://www.linuxdoc.org
>                                       Finger me for my public key
>
>Your code should be more efficient!
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What good is it to remove 0 pieces of whitespace from the end of a
string?  I would suggest changing s/\s*$// to s/\s+$// for logic reasons.

It's pointless to remove 0 or more of something from the end of a string,
when you could just remove 1 or more of them.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
*** I need a publisher for my book "Learning Perl Regular Expressions" ***

Reply via email to