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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |