tie::File 500 Internal Server Error???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • casybay
    New Member
    • Oct 2007
    • 35

    tie::File 500 Internal Server Error???

    Hi folks,

    Perl is always killing me. I always do it on my computer first and then upload to the server in our lab. And oh my, never ever be correct to run on the lab. This time I got the internal error. I tried to add and delete multiple lines and found out that is possibly due to tie::File.

    Could you please help me to solve the problem? I am dying for it :(

    Here's the code.
    [code=perl]
    #!/usr/bin/perl

    #use CGI::Carp qw(fatalsToBrow ser);

    #use strict;

    use CGI;

    use Tie::File;

    $query = new CGI;

    $data_file="nam eList.cgi";

    open(DAT, $data_file) || die("Could not open file!");

    @raw_data=<DAT> ;

    tie @line, 'Tie::File', $data_file or die("Could not open file!");

    print $query->header();

    print "Content-type: text/html\n\n";

    print "<HTML><HEAD>\n ";
    print "<TITLE>Thanks! </TITLE></HEAD>\n";
    print "<BODY>";

    $first = $query->param("first") ;
    $last = $query->param("last" );
    $email = $query->param("email") ;



    print "<P>$first $last, thank you for signing up! Please click <a href=\"list.pl\ ">here</a> to see the signup table for confirmation and don't repeatly signing up.</P>\n";



    $count = 0;

    @WS = $query->param("ws");

    foreach $ws(@WS){

    $line[$ws-1].="$first $last, $email|";

    }

    close(DAT);

    print "</BODY>\n";

    print "</HTML>\n";
    [/code]

    -------------------------------------------------------------------------------------------------------

    And I've tried use warnings, add and remove -w.....doesn't work.........cr ying T-T

    Cannot appreciate more.
    Last edited by eWish; Oct 25 '07, 02:16 AM. Reason: Added Code Tags
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    Welcome to TSDN Casybay!

    You have posted code into the forum without using proper code tags. It is best practice here on TSDN to wrap all code posted into the forum in code tags.

    Code tags start with &#91;code] and end with [/code]. If you need an example other than this one, the please refer to the REPLY GUIDELINES (or POSTING GUIDELINES if you are starting a discussion) to the right of the Message window. You will find the examples and suggestions for posting there.

    In addition, you can also add the language to your code tags. Here is an example:

    &#91;code=pe rl]
    <some code>
    [/code]

    Please know that I have fixed your posts above to include the proper code tags. Please be sure and use code tags in all of your future posts here on TSDN.

    - Moderator

    Comment

    • eWish
      Recognized Expert Contributor
      • Jul 2007
      • 973

      #3
      What errors did you get? Did you check the error logs to see what was logged? I would uncomment the following lines and add use warnings; as well.
      [CODE=perl]use CGI::Carp qw(fatalsToBrow ser);
      use strict;[/CODE]Then I would declare the variables correctly using my. What OS are you using?

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        You're not actually using Tie::File to do anything in the code you posted. Are you just experimenting?

        Comment

        • casybay
          New Member
          • Oct 2007
          • 35

          #5
          To eWish, sorry for that. I didn't notice that. I am using Windos XP in my computer and the lab's server OS is Linux, and for both of them, I am using Apache.
          To KenvinADC, yes, I did. Please see line 44. I am going to write something to the file as my understand.
          Thank you so much for you guys' replies.

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            Sorry, I missed those lines.

            Untested code:

            [code=perl]
            #!/usr/bin/perl

            use CGI::Carp qw(fatalsToBrow ser);
            use strict;
            use warnings;
            use CGI;
            use Tie::File;
            use Fcntl;

            my $query = new CGI;
            print $query->header,$quer y->start_html('Th anks!');

            my $data_file = "nameList.c gi";

            tie my @line, 'Tie::File', $data_file, mode => O_RDWR or die "$!";

            my $first = $query->param("first") ;
            my $last = $query->param("last" );
            my $email = $query->param("email") ;

            print $query->p(qq{$first $last, thank you for signing up! Please click
            <a href="list.pl"> here</a> to see the signup table for
            confirmation and don't repeatly signing up.});

            my @WS = $query->param("ws");

            foreach my $ws (@WS){
            $line[$ws-1].= "$first $last, $email|";

            }
            untie @line;
            print $query->end_html;
            [/code]

            Comment

            • casybay
              New Member
              • Oct 2007
              • 35

              #7
              KenvinADC, I will try it tomorrow when I go to the lab. Appreciate that :)

              Comment

              • casybay
                New Member
                • Oct 2007
                • 35

                #8
                Hi KenvinADC, it seems like the code you modified for me still doesn't work.

                Comment

                • KevinADC
                  Recognized Expert Specialist
                  • Jan 2007
                  • 4092

                  #9
                  Unless you can be more specific I can't help.

                  Comment

                  • casybay
                    New Member
                    • Oct 2007
                    • 35

                    #10
                    Sorry for that KevinADC, cuz I am waiting for my permission to access to the error log, so before that, I cannot tell you more specific about the error.
                    Since there's something wrong with tie::File, could anyone inspire me what could possibly cause error with this function? Or is there anyother way to read and write a line from and to a file using perl?
                    Appreciate :)

                    Comment

                    • KevinADC
                      Recognized Expert Specialist
                      • Jan 2007
                      • 4092

                      #11
                      I don't think the problem is with Tie::File. If you are running the script via a web server and getting a 500 internal server error the script may not even be compiling. Could be the path to perl is wrong or the scripts permissions are wrong or you uploaded the script in binary mode instead of text mode. If the problem was with Tie::File the CGI::Carp module should be printing an error to the screen. Any idea what version of perl you are using? Can you get any CGI scripts to work?

                      Comment

                      • casybay
                        New Member
                        • Oct 2007
                        • 35

                        #12
                        Yes, I can run other perl script which doesn't have that tie::File.
                        And I finally get my error log, here is the related error:

                        Can't locate Tie/File.pm in @INC (@INC contains: /usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at /spare/WWW/cgi-bin/list.pl line 5.
                        BEGIN failed--compilation aborted at /spare/WWW/cgi-bin/list.pl line 5.

                        Comment

                        • KevinADC
                          Recognized Expert Specialist
                          • Jan 2007
                          • 4092

                          #13
                          The problem is you are running a very old version of perl. Tie::File is not installed. I do not know if it will even work with such an old version of perl (5.005) . That mst be at least 10 years old. So for know you can't use Tie::File.

                          Comment

                          • casybay
                            New Member
                            • Oct 2007
                            • 35

                            #14
                            10 years old??? Oh my, yea....I searched on internet, saying that I missed a module, and I can add it to the makefile.pl. Hum....then I should let the website adminstrator to fix up that first. Thank you so much.

                            Comment

                            • casybay
                              New Member
                              • Oct 2007
                              • 35

                              #15
                              The module is installed, but I still get another error. Can anyone help??? Than.........ks !!!
                              Error:
                              Premature end of script headers:

                              Comment

                              Working...