/ Published in: Perl
At one point I wanted to give every image on my site an ALT tag. I did, with some help from [email protected]
Expand |
Embed | Plain Text
#/usr/local/bin/perl -w use strict; ############################################################ # # # # # # # NOAH SUSSMAN # # # # insert_alt # # # # Created 5/11/01 at 01:38 PM # # # # Insert ALT element into IMG tags that lack it. The alt # # text inserted is identical to the contents of the <TITLE># # tag -- or not. # # # # # ############################################################ =item THIS NEEDS TO BE ADJUSTED SO IT WORKS WITH JSP (02:35:50) VERSUSearth: I'll have to adjust my insert_alt script to take JSP into account next time (02:36:35) mitiege: yep- I'm guessing you are looking for the first closing sign and inserting before that.. (02:36:47) mitiege: a simple fix would be to put the alt first in the img tag... (02:37:06) VERSUSearth: yeah that's probably a good idea =cut $^I=".bk"; #undef $/; # read in whole file, not just one line my $text = "" ; #Insert blank alt attribute while (<>) { #m{<title>(.*?)</title>}ix; #my $text = $1; #Use the document title as the ALT text } print "$_"; }
You need to login to post a comment.
