Anybody know how this Web site abbreviates/shortens the URL links posted in these threads? I'd like to incorporate this feature into http://www.usedflutes.com and http://www.usedviolins.com for the often very long URL links posted there.
Many thanks in advance,
In general you could do this:
[size=2]$text =~ s|(<a href="[^"]*?">)(.*?)(</a>)|$1 . (length $2 > 20 ? substr($2, 0, 16) . '...' : $2) . $3|eg;[/size]
Though this method of identifying anchors in HTML is very specific and will not match all valid occurances. You should use HTML::TokeParser for this if possible.
Wow! Thanks Jeff. Unfortunately, this is quite a bit "over my head," so I have some homework to do to see if I can figure out how to integrate it into the MySQL script.
Thanks again Jeff for the help, :-)
OK - I'm not sure how to do this...
I did read about TokeParser from the link you sent as well as a general search on Google for other users of it ( for example, http://wdvl.internet.com/Authoring/Languages/Perl/PerlfortheWeb/TokeParser.html ). However, I'm still not clear on how to integrate/modify it into the existing script http://usedflutes.com/MySQL_script.txt ( $val = the URL link ).
BTW, somebody recently posted a very long URL on http://www.usedflutes.com which is a good example of what I'm trying to abbreviate ( http://search.freefind.com/find.html?id=6901309&pageid=r&mode=ALLfirstname.lastname@example.org )
It looks like this forum abbreviates URLs formatted as 35 characters -> ... -> 15 characters. Something similar to this would be great.
Thanks again Jeff for any more help on this you can provide,
Got it! :-)
(see "The Mad Hatter" http://www.perlmonks.org)