Randal L. Schwartz wrote:
"Stuart" == Stuart Johnston <[EMAIL PROTECTED]> writes:


Stuart> The truncate function of the String plugin allows for a suffix that
Stuart> will be appended to the truncated string.  A patch was added 'to not
Stuart> append suffix if the string is already shorter than the required
Stuart> length'.  This is not explained in the docs.

Stuart> Since my problem requires adding the suffix regardless of length, I
Stuart> did not assume that it would functiion this way.  An update to the
Stuart> docs to mention this condition would be nice.

If you want to add a suffix, regardless of length, you can simply
use the "_" operator.  See the example there for a use of the suffix
inserted when truncation *has* happened.


I'm not sure what example you are referring to but my problem is that I need the complete, final string to be less than a certain length so I can't simply use "_".


I am creating sequence names for PostgreSQL that look like 'tablename_colname_seq' where the whole thing will be 30 chars or less and the truncation will happen on the 'tablename' part, not the 'colname_seq' part. I just wrote a perl sub to take care of it:

sub { my $s = '_' . $_[1] . '_seq';
      return substr($_[0], 0, 30 - length $s) . $s; }



_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to