Page 1 of 1

Coding efficiency

Posted: Wed Oct 03, 2001 4:39 pm
by MiniMe
is there a way to combine these statements to be more efficient??
<strlen $TITLE>
< if $ret gt 50>
<substr $TITLE 0 50>
<sum "%s" $ret "...">
$ret
</if>

to something like
<sum "%s" <substr $TITLE 0 50> "...">
$ret


Don't ask me why.. one of our perl developers asked..

M.

Coding efficiency

Posted: Wed Oct 03, 2001 4:52 pm
by mark
No need to check first. The following is that same as what you propose:
<substr $TITLE 0 50>
<sum "%s" $ret "...">

Coding efficiency

Posted: Wed Oct 03, 2001 5:29 pm
by John
If you only wanted to put the ... after titles longer than 50 you could also do something like:

<sandr ".{50}.+" "\1..." $TITLE>
$ret