31 users online (1 members and 30 guests)  


  Results 1 to 2 of 2

Related

  1. xml file reading    Forum: Javascript Forum
    Replies: 0
  2. Reading file from different HD    Forum: CGI Perl Forum
    Replies: 0
  3. Regarding .XLS file reading and display    Forum: CGI Perl Forum
    Replies: 0
  4. problem with excel file reading in Perl-Cgi    Forum: CGI Perl Forum
    Replies: 3
  5. reading from text file to textarea using vbscript    Forum: Website Scripts Forum
    Replies: 0
  1. #1
    sdja's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2007
    Posts
    1

    problem in file reading

    hi...
    i am beginner in perl cgi programming..i am atempting to read from a file....
    my cgi script is

    #!c:\perl\bin\perl -wT
    #print "content-type: text/html \n\n";
    use CGI qw(:standard);
    use strict;
    print header;
    print start_html ("ebanking");

    my $ne=param('name');
    my $pwid=param('pwd');

    open(FP,"input.txt") or die "cannot open file";
    @raw_data=<DAT>;
    close(DAT);

    foreach $account (@raw_data)
    {
    chop($account);
    ($w_name,$pswd,$accno,$address,$type,$balance)=spl it(/\|/,$account);
    if(( $ne eq $w_name) and ( $pwid eq $pswd))
    { print " \nName: $w_name Balance: $balance" ; }
    else
    {print "\n User name and password not match"; }

    }#fore each

    print end_html;

    when the above code is executed using WIN 32 apache it shows an internal error...this is the syntax given in every website....
    if i remove the print statements corresponding to cgi and run in command line perl it works perfectly....

    please help...

  2. #2
    xmassey's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    100

    Re: problem in file reading

    Hello,
    Couple of things. If you remove the print statements then it will work, because you haven't declared the content type:
    You use:
    #print "content-type: text/html \n\n";

    When it should be:
    print "content-type: text/html \n\n";
    Because you added a # at the beginning, perl reads that line as being a COMMENT not code



Tags for this Thread