in reply to MyInclude
Here is slightly different version that returns a scalar instead of an array.
When you call this sub:sub file2scalar { my $filename = shift; return "Error: $filename doesn't exist" unless -f $filename; open FH, $filename || return "Error: can't read $filename"; return do{local $/; <FH>}; }
$include will either contain the contents of the file or an error message. Instead of differentiating between the two, i recommend just printing $include to the browers, much like PHP does when you give it's include() function a file that doesn't exist or can't be read. (of course, my real recommendation is to just go ahead and install CGI::SSI instead)my $include = file2scalar('foo.html');
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
---|