PHP to Perl - simple script

Discussion in 'Software' started by peanut 182, Jul 2, 2008.

  1. peanut 182

    peanut 182 Private E-2

    can any one turn this into perl?
    i have tryed but failed, would be very greatful

    PHP:
    fwrite<?php

    $comment
    =$_REQUEST["comment"];
    $filename 'test.txt';
    $comment "message: $comment";

    !
    $handle fopen($filename'a');
    fwrite($handle$comment."\r\n\r\n" );
    fclose($handle);
        


        
    header'Location: yes.html' )

    ?>

     
    Last edited: Jul 2, 2008
  2. Kodo

    Kodo SNATCHSQUATCH

    good christ.. why are people still using perl for web stuff. it was never meant for it..
     
  3. peanut 182

    peanut 182 Private E-2

  4. PC-XT

    PC-XT Master Sergeant

  5. PC-XT

    PC-XT Master Sergeant

    Here it is to try:
    Code:
    #! /usr/bin/perl
    
    my $comment=$cgi->param('comment');
    open(my $handle, ">>", "test.txt") or die 'Error. Please press your browser's Back button and try again.';
    print $handle "message: $comment\r\n\r\n";
    close $handle;
    print "Your message: $comment\n<br>was received."
    If it doesn't work, let me know, and I'll try to fix them. I added confirmation messages. I think I also suppressed error messages, but if you want to enable them, add these lines before the main code, but after the #! first line:
    Code:
    use strict;
    use warnings;
    You also might want to add the target=_blank attribute to the form html tag to open this in a new window. (Then you can delete that part about pressing the back button, and just keep the try again part.) Alternatively, you could edit them to write better html.
    I assume you know how to upload this and make it executable. Instructions will probably be on the host's site.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds