First and foremost, I have to say this works fine on an older RHEL5.3/Apache system. Look at this code:
Code:
#!/usr/bin/perl -w
my $foo='/tmp/*';
my @glob=glob($foo);
my $size=scalar(@glob);
$foo='/usr/*';
@glob=glob($foo);
my $size2=scalar(@glob);
$foo='/tmp2/*';
@glob=glob($foo);
my $size3=scalar(@glob);
print "Content-type: text/html\n\n";
print "<html><head>\n";
print "SIZE: $size SIZE2: $size2 SIZE3: $size3\n";
print "</head></html>\n";
All it does is a glob to return a list of the number of files in 3 different directories and report how many there are. Running from a shell, it produces exactly what I'd expect. However if I put the code into /var/www/cgi-bin and invoke it from a browser it reports 0 for both /tmp and /tmp2.
My initial thought was (and still is) it might be some sort of permission problem so I did "su apache" so I could be the same user as the webserver and when I run from the command line it still works correctly. So it's not the user but the webserver itself that is causing this odd behavior.
This is driving me crazy and I'm out of ideas. Anyone have any suggestions for what other tests I might try?
Btw - if I count the files using opendir/readdir, it does work correctly and I may ultimately have to redo my code to use them, but I'd really like to understand what's going on and whether or not this might be a bug in mod_perl.
-mark