[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Bad Subroutine



on 6/26/98 6:20 PM , Matt Kraft  wrote:

>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
>
>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";
>            }

#####  ADDED LINE #####
     else {print FIRST "$first_line"}

>	}
>    }
>   close(FIRST);
>}
>

If the line didn't match, you weren't printing anything at all..

Jeremy

Jeremy Lee                     |   Owner- 
Sound Designer/Technician      |   Madrone Ridge Sound Design
Oregon Shakespeare Festival    |   Sound for Multimedia
                               |
                 http://www.ashland.net/madrone
-------------------------------------------------------------------------
"Is it not strange that sheeps' guts should hale souls out of men's 
bodies?"  
        -  Wm. Shakespeare

"The mime sang:"  - Alfred Jarry
------------------------


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch