Ok, I've been struggling with this for days, now...
Problem: I have a CGI script that is getting too long, and I would like to separate the code into files for further expansion and options, however upon doing so the "open" and "opendir" commands in my script have ceased to execute.
Everything works fine except this, but this is a MAJOR problem, since the
script is mainly for data modification (stored in a text file).
Here's an example...
file 1:
use CGI qw(:all);
require "file2.pl"; // see below
print header;
print "<html><body>";
&file2sub(); # execute the external subroutine
print "<br>end";
print "</body></html>";
file2.pl:
open(NEWFILE, "file.txt") || print "error accessing /data/file.txt";
print <NEWFILE>;
close(NEWFILE);
};
1;
file.txt:
If anyone can figure this out, or knows what I'm doing wrong: please, please let me know!
It would be greatly appreciated.
Thanks,
Jeff
Problem: I have a CGI script that is getting too long, and I would like to separate the code into files for further expansion and options, however upon doing so the "open" and "opendir" commands in my script have ceased to execute.
Everything works fine except this, but this is a MAJOR problem, since the
script is mainly for data modification (stored in a text file).
Here's an example...
file 1:
Code:
#!/usr/bin/perl -w use CGI qw(:all);
require "file2.pl"; // see below
print header;
print "<html><body>";
&file2sub(); # execute the external subroutine
print "<br>end";
print "</body></html>";
file2.pl:
Code:
sub file2sub() { open(NEWFILE, "file.txt") || print "error accessing /data/file.txt";
print <NEWFILE>;
close(NEWFILE);
};
1;
file.txt:
Code:
success! the file was read by the external subroutine!<br>If anyone can figure this out, or knows what I'm doing wrong: please, please let me know!
It would be greatly appreciated.
Thanks,
Jeff