in reply to Short URL?

Use substr. Also, testing if $val5 is defined and also not an empty string is redundant; I've changed it below.
my $page_link; if ($val[5]) { # construct link if value is not NULL (undef) or empty my $linktext = $val[5]; $linktext = substr($linktext, 0, 35) . "..." . substr($linktext, - +15) if length($linktext) > 53; $page_link = a ({-href => $val[5]}, $linktext); } ### other variables here ### then print " - $page_link" if defined ($page_link);

Update Fixed typo.

Update2 Added note about if condition.

Update3 Just noticed that in the root node the 5's are linked. Since they aren't in code blocks, I assumed that you typed $val[5] and they were turned into links without you realizing. Next time use the <code> tags. (OT, looking at all the updates I've done, I should probably stop popping those penguin mints... ;-)

Replies are listed 'Best First'.
Re: Re: Short URL?
by bobafifi (Beadle) on Apr 06, 2003 at 02:55 UTC
    Thanks so much! Your fix works great :-) -Bob p.s. Thanks to everybody else on this post too -- I haven't had a chance to look at all your replies yet, but will. Thanks again.