http://www.perlmonks.org?node_id=375493


in reply to Re: In search of a better way to trim string length
in thread In search of a better way to trim string

Thanks, theAcolyte!

Ran your code. I think you need to add a space here:

$clipped .= $_; # orginal $clipped .= "$_ "; # changed
With your code, when I passed the sub a string such as "this is a very long sentence without spaces in between", it gets transformed to "thisisaverylongsentencewithout" i.e. the original spaces were gone.

cheers

Replies are listed 'Best First'.
Re^3: In search of a better way to trim string length
by theAcolyte (Pilgrim) on Jul 20, 2004 at 00:30 UTC
    blah ... right you are! See what I get for posting untested code? Then again, I always post untested code ... :P