i made a guestbook and i want to add some function. eg:del post and modify post i can do the del function , but don't know how to do the modify, below is my admin.pl
#!/usr/bin/perl print "content-type:text/html\n\n"; $admin ="sonic"; if($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); }else{ $buffer=$ENV{'QUERY_STRING'}; } @pairs=split(/&/,$buffer); foreach $pair(@pairs){ ($name,$value)=split(/=/,$pair); $value=~tr/+/ /; $value=~s/%([0-9a-fA-F][0-9a-fA-F])/pack("C",hex($1))/eg; $value=~s/</&lt;/g; $value=~s/\n/<br>/g; $FORM{$name}=$value; } open(READ,"guestbook.dat"); @lines=<READ>; close(READ); my $pw = $FORM{'password'}; my $adminmsg = $FORM{'ownermsg'}; my $modnum = $FORM{'postid'}; if ( $admin eq $pw ) { foreach $line(@lines) { ( $number,$sign_name,$sign_email,$sign_homepage,$sign_icon,$sign_time, +$sign_msg ) = split ( /__/, $line ) ; if ( $modnum ne $number ) { push ( @data , $line ); open(WRITE,">guestbook.dat"); print WRITE @data; close(WRITE); } } print "Loading ..."; print "<META HTTP-EQUIV=Refresh CONTENT=2;URL=viewguestbook.pl?action= +view_post&start=0&end=$show>"; }else{ print <<EOF; <center>wrong password<br> Please <a href=javascript:window.history.back()>go back</a> ! </center> EOF }
if i want modify a post message($sign_message)only,
then write back into guestbook.dat ,
how to write back to the orginal place ,
is it use sort and resever ?
hope someone can understand my question!!

In reply to how can i modify the array ? by 12monkey

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.