On Fri, May 03, 2002 at 06:08:19AM -0700, Paul Makepeace wrote: > > for (my $last = -1; 30 < length and $last != length; $last = length) { > s/_[^_]+$//; > } > > for(;;). Heh. > > This still leaves the possibility of a long URL. Perhaps shortening it > to a certain length first, then removing words?
Or maybe something like: tr#a-zA-Z0-9#_#cs; /^(.{1,30})(_|$)/ ? $1 : substr $_, 0, 30; -- Nick