I am trying to write a simple script to insert ALT attributes into IMG tags
that don't have them, leaving other IMG tags untouched.

The problem is that I can't figure out how to tell Perl to search for
strings beginning with "<IMG", ending with ">" AND not containing "ALT="
(and it has to do this over multiple lines as well!).

This is my code so far, any comments would be hugely appreciated:

#! -w
use strict;

undef $/;          

my $text = "hello" ;

while (<>) {

    unless (m{<img.*?alt=.*?>}ix){
    
        s{(<img)(.*?)>}{$1$2 alt="$text">}gsix;
    
    }
    
    print "$_";

}





-- 
Noah Sussman
Senior Web Developer
Deltathree, The IP Communications Network
75 Broad St, 31st Floor
New York, NY 10004
tel 212-500-4845
fax 212-500-4888
[EMAIL PROTECTED]
www.deltathree.com


"Nature will tell you a direct lie if she can."

    -Charles Darwin


Reply via email to