0

I am working on converting the interface of a perl web application to Ext and intended to use CGI-ExtDirect-2.02 library.

I encountered a problem though, which, after many hours of struggling, still remains unresolved.

In the simplest use case the problem is: when I am adding the following lines to the action method, for example, to the Demo/TestAction/getGrid, an error occurs in the Router.pm. The same error appears both when executed under apache or using included into the library p5httpd.pl server.

When I remove while(<FILE>) loop, the error goes away and everything else works fine.

System configuration is:

SunOS 5.10, apache 2, perl 5.12.1.

Lines I add:

open(FILE, "</tmp/test.txt") or die("Can't open file: $!");
while (<FILE>) {
    ;
}
close(FILE);

Error:

5571 17:58:08 Server started on port 5000.
5571 17:58:08
5571 17:58:08 Point your browser at http://localhost:5000
5571 17:58:11 <- localhost: GET /direct-grid.html HTTP/1.1
5571 17:58:11 -> 200 OK /direct-grid.html: 803 bytes sent as text/html
5571 17:58:11 <- localhost: GET /example.css HTTP/1.1
5571 17:58:11 -> 200 OK /example.css: 1501 bytes sent as text/css
5571 17:58:11 <- localhost: GET /direct-grid.js HTTP/1.1
5571 17:58:11 -> 200 OK /direct-grid.js: 1599 bytes sent as application/x-javascript
5571 17:58:11 <- localhost: GET /cgi-bin/api.cgi HTTP/1.1
5571 17:58:11 -> exec'ing api.cgi
5571 17:58:13 <- localhost: POST /cgi-bin/router.cgi HTTP/1.1
5571 17:58:13 <- Content-length: 119, type: application/json; charset=UTF-8
5571 17:58:13 -> exec'ing router.cgi

Can't call method "result" on an undefined value at
/usr/perl5/site_perl/5.12.1/RPC/ExtDirect/Router.pm line 136. 
5571 17:58:13 -> 500 Internal Server Error Premature end of script headers.
<br> Status: 65280<br>Have a look at server log for stderr output of /cgi-bin/router.cgi
chrsblck
  • 3,948
  • 2
  • 17
  • 20
dmitreyg
  • 2,615
  • 1
  • 19
  • 20
  • Are you sure there's not more code in the `while` loop? Looks a lot like you cropped what came in front of that `;`... – simbabque May 18 '13 at 22:51
  • It's just in my case it does not matter what's inside the loop. – dmitreyg May 18 '13 at 22:54
  • Have you looked at the `stderr` output in the server log as it says in the last line of the error message? What does that say? – simbabque May 19 '13 at 09:35
  • All stderr output goes to the console in this case. – dmitreyg May 21 '13 at 00:37
  • 1
    You could provide minimal script which reproduce this behavior. – mpapec May 23 '13 at 06:37
  • What you've posted doesn't replicate the issue. You say, "`STDERR` goes to the `console`". Do you care to share what it outputs? For clarification: if you have that `while` loop empty, as you've shown, does same exact error occur? – chrsblck May 23 '13 at 16:13
  • This message goes to STDERR - Can't call method "result" on an undefined value at...line 136 As for the "while"... Empty while gives this error. If I, say, add print STDERR $_ inside the loop, lines are printed, but then the same error still occurs. – dmitreyg May 23 '13 at 19:48

1 Answers1

0

If the loop has nothing to do with the problem, then there is probably a problem with the FILE superglobal conflicting with something. Try changing it to something like

open my $if, "<", "/tmp/test.txt";
while(<$if>) {
    # whatever
}
close $if;
AKHolland
  • 4,435
  • 23
  • 35