Could this be a buffering problem?
Maybe $|=1 at the top of the script would help?
Does it need a seek()? Hmm....
--- Morgan Seppy <[EMAIL PROTECTED]> wrote:
> I've inserted text into a file before, but I can't seem to figure
> this one out. I'm trying to create a guestbook / message list.
> I'm taking information from a form and trying to insert it at a
> certain spot in a file, namely, the top of the list. My form works
> fine and I have no trouble getting the information into the file,
> but it keeps appending to the end of the file.
>
> These are the first few lines in guestbook.html:
> <html>
> <head>
> </head>
> <body>
> <table cellspacing=2 cellpadding=4 border=0>
>
> <!-- TOP -->
>
> .... list of entries in table form ....
>
>
>
> Perl program snippet:
>
> open( GBOOK, "+<../htdocs/guestbook.html" ) or die( "Couldn't open
> GBOOK:
> $!\n" );
>
> # Find top of list and insert entry
> while( <GBOOK> )
> {
> if( /^<!-+\s+TOP\s+-+>$/ )
> {
> print GBOOK "found TOP<br>\n";
> ... # add new entry
> }
> }
>
> close( GBOOK ) or die( "Couldn't close GBOOK: $!\n" );
>
>
> Originally, I had the first line of the while() as
> next unless /^<!-- TOP -->$/ ;
> but that didn't work either, so since then it has been kludged into
> the
> above version.
>
> My confusion is apparent in these questions:
> 1. Why doesn't my regex work?
> 2. Why does the entry get added at the end of the file if the regex
> failed?
>
> Thanks for any help you can provide,
>
> Morgan
> [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/