MDK@M-D-K.com,Internet writes: >I have this subroutine in a program of mine for the web that's just not >working. What it's supposed to do is, open a file, find the line that >reads <!--$first_next-->Not Posted Yet and then put ><!--$first_next-->$subject<!--end$first_next--> in it's place. But >instead, it prints <!--$first_next-->$subject<!--end$first_next--> and >erases over everything else in file. Anyone know how to fix this? The >subroutine is below. > >Matt Kraft > It looks like you forgot to write all the lines that don't match your search criteria. You pull all the lines out of the file and then when you rewrite it, you only write when it finds the matching line - all the other lines are ignored. Try this: sub first_prev_page { open(FIRST,"$basedir/$mesgdir/$first_prev\.$ext") || die $!; @first = <FIRST>; close(FIRST); open(FIRST,">$basedir/$mesgdir/$first_prev\.$ext") || die $!; if ($followup == 0) { foreach $first_line (@first) { if ($first_line =~ /<!--$first_next-->Not Posted Yet/) { print FIRST "<!--$first_next-->\n"; print FIRST "$subject\n"; print FIRST "<!--end$first_next-->\n"; } else { # # you forgot to do this: # print FIRST $first_line; } } } close(FIRST); } ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch