Hello :-) I am totally new to perl. I'm trying to get a madlibs story working. (I know there is a template called weblibs for this but couldnt get that to work)

Anyway I have got it working but all new stories are appended/added AFTER one another - I want the last one to be listed FIRST in the html - file instead of last. Is this possible?

I have an input.html with forms that send the nouns/adjectives to tull.pl that generates the story and a link to the resulting stories.html file where the stories are listed (the "wrong" way)

here is my .pl file:
#!/usr/bin/perl local ($buffer, @pairs, $pair, $name, $value, %FORM); # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; } # Split information into name/value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $FORM{$name} = $value; } $navn = $FORM{navn}; $navn2 = $FORM{navn2}; $adj1 = $FORM{adj1}; $bann1 = $FORM{bann1}; open(my $fh, '>>', 'stories.html'); print "Content-type:text/html\r\n\r\n"; print $fh "<HR color=#000000 SIZE=4>\n<h3>$navn something. $bann1!!! s +houted $navn! A $adj1 $navn2 something $navn!! something $navn said $ +bann1! Hihi.</h3>\n"; print "<a href='stories.html'>READ STORY</a>"; close $fh;

In reply to appending to html at beginning by Limbomusic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.