Loading ...
Sorry, an error occurred while loading the content.

file acess

Expand Messages
  • alexandru lugojan
    Hello, I am a beginner in Perl. I made a file (test_perl.htm) which contains a form with a field named CAMP1: Test PERL
    Message 1 of 2 , Apr 12, 2005
    • 0 Attachment
      Hello,

      I am a beginner in Perl. I made a file (test_perl.htm)
      which contains a form with a field named CAMP1:

      <html>
      <head>
      <title>
      Test PERL
      </title>
      </head>
      <body>
      <center>
      Welcome
      </center>
      <br>
      <table border="0"
      cellpadding="0"
      cellspacing="19"
      align="center">
      <tr>
      <td>
      Sign up
      <br>
      <form name="formular1"
      action="test_perl1.cgi"
      method="post">
      <input type="text"
      name="camp1">
      <input type="submit"
      value="Sign up"
      name="buton1">
      </form>
      </td>
      <td bgcolor="#000000"
      width="1">
      </td>
      <td>
      Login in
      <br>
      <form name="formular2"
      action="test_perl2.cgi"
      method="post">
      <input type="text"
      name="camp2">
      <input type="submit"
      value="OK"
      name="buton2">
      </form>
      </td>
      </tr>
      <tr>
      <td colspan="3"
      align="center">
      <form name="formular3"
      action="test_perl3.cgi"
      method="post">
      <input type="submit"

      value="Environment"
      name="buton3">
      </form>
      <form name="formular4"
      action="test_perl4.cgi"
      method="post">
      <input type="submit"
      value="Data Base"
      name="buton4">
      </form>
      </td>
      </tr>
      </table>
      </body>
      </html>

      The form is processed by a program in Perl
      (test_perl1.cgi), wich reads the value of field CAMP1
      comparing it with the existing lines in the file
      (test_perl.txt).

      #!/usr/bin/perl -w

      use CGI;

      $query = new CGI;

      print $query->header;

      if (open (fisier, "perl/test_perl.txt"))
      {
      print "<br>Hello <b>";
      $nume = $query->param('camp1');
      print $nume;
      print "</b><br>";

      @text=<fisier>;

      foreach $linie (@text)
      {
      print "linie", $linie, "<br>";
      print "nume", $nume, "<br>";

      if ($nume eq $linie)
      {
      print "You are allready a member.";
      }
      else
      {
      print "Welcome, new member.";
      }
      }
      }
      else
      {
      print "file not open <br>$!";
      }

      close(fisier);

      The problem is, that the condition is allways FALSE. I
      make a mistake but i do not know where. Can you help
      me?

      Thanks





      __________________________________
      Do you Yahoo!?
      Yahoo! Small Business - Try our new resources site!
      http://smallbusiness.yahoo.com/resources/
    • merlyn@stonehenge.com
      ... alexandru Hello, alexandru I am a beginner in Perl. I made a file (test_perl.htm) alexandru which contains a form with a field named CAMP1: alexandru
      Message 2 of 2 , Apr 12, 2005
      • 0 Attachment
        >>>>> "alexandru" == alexandru lugojan <lugojanalexandru@...> writes:

        alexandru> Hello,

        alexandru> I am a beginner in Perl. I made a file (test_perl.htm)
        alexandru> which contains a form with a field named CAMP1:

        alexandru> if (open (fisier, "perl/test_perl.txt"))

        alexandru> The problem is, that the condition is allways FALSE. I
        alexandru> make a mistake but i do not know where. Can you help
        alexandru> me?

        If that's the condition that is "always false", what's the value
        of $!, since you display it later?

        Also, use uppercase for filehandles. Otherwise, they collide
        with built-in names.

        You're probably having the classic problem with CGI... you've
        used a relative pathnamed, but I bet you're not sure what directory
        you're in when the script runs. :)

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      Your message has been successfully submitted and would be delivered to recipients shortly.