This is the easiest way, in my opinion.  It'll work on files passes as 
command line arguments.  Beware the replacing though, files will be 
modified in place and data may be lost!

#!/usr/bin/perl -pi

s/leftmargin="0".*bgcolor="#3c3939"//g;
s/bgcolor="\#5A5D4E"/class="topOfPic"/ig;

On Monday, September 2, 2002, at 02:09  PM, Tim Booher wrote:

> Hello, I am currently frustrated trying to do a simple find and replace
> on a file, but the three open options: Read, Write and Append don't seem
> to give me what I want. For example, Read, works on the finding, but
> nothing will replace. Write erases all the files and leaves me with
> blank files and append adds to the end.
>
> I tried something like:
>
> open(MYFILE,'+<',$myfile);
>
> and that didn't work. If you are interested here is my code:
> .. . .
> open(HTMFILE,'+<', $filename) or die "Can't Open: $!";            # now
> go through all .htm files and make changes
>                   while (<HTMFILE>) {
>                         $_ =~ s/leftmargin="0".*bgcolor="#3c3939"//g;
>                         $_ =~ s/bgcolor="\#5A5D4E"/class="topOfPic"/ig;
>                   }
>                   close(HTMFILE);
>                   . . .
>
> any thoughts . . ?
>
> thanks,
>
> tim
>
James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to