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


in reply to Oneliner with substring trimming and padding

What about the following approach:

  1. adding a "maximum number" of padding-characters at the end of your substring
  2. cutting the substing back to the desired number of characters
That way you avoid calculating the real number of needed padding-characters

Just an idea. Rata