# Set $header_file to the PATH to header.incl my $header_file = 'header.incl'; # Call load_file() which takes a filename as an argument and # returns the contents of that file. Then print what load_file() # returns. print load_file($header_file);
sub load_file { my($file,$html) = shift; $html = ''; open(FILE, "$file") or die "Cannot open $file for reading: $!" while(<FILE>) { $html .= $_; } return $html; } # Hope that helps. On Wed, 2003-10-01 at 23:14, Bryan Harris wrote: > I'm just barely starting into the world of CGI. I think this is going to be > the best thing I ever did. What I think I want to do is have a library of > HTML snippets (like a generic header and footer), and then use perl to > output them in order along with any custom content. > > What I'm interested in is what's the easiest way to print the contents of a > file? For example, if I want to output my header file, "header.incl", how > can I print the contents of that file the easiest (and most generally > compatible)? > > I've tended to shy away from backticks because I kind-of feel like they're > not "real" perl, and somehow less portable. Should I feel that way? > > TIA. > > - Bryan > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]