Will that find IMG tags even if they span multiple newlines, though?


> From: "scott lutz" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Mon, 14 May 2001 23:36:55
> To: [EMAIL PROTECTED]
> Subject: Re: negative matching?
> 
> maybe something like
> 
> foreach $line (@file_array){
> if $text =~ m/<img/{
> unless $text =~ m/alt/;
> $text =~ $text + $alt_text
> }
> }
> 
> 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
> 
> 
> 
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 

Reply via email to