On Thursday 02 Oct 2003 10:25 am, Owen wrote:
> On Wed, 01 Oct 2003 23:14:00 -0700
>
> Bryan Harris <[EMAIL PROTECTED]> wrote:
> > 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)?
>
> Firstly specify the file;
>
> $file = "/location/of/header.incl";
>
> Next open it for reading
>
> open (FH, "$file") or die "Cannot open file $file $!";
>
>
> Lastly, go through the file line by line and print them
>
>
> while(<FH>){
> print "$_"; #$_ is the value of the current line
> }
>
> You may wish to change the print line to   print "$_<br>\n";    if you want
> a new line on your html for each new line in your file.
>
>
>
> Owen

Hi Owen,

One thing you forgot was to close the file.  Also, don't forget that you can 
do it with less typing:

$file = "/location/of/header.incl";
open (FH, "$file") or die "Cannot open file $file $!";
print while(<FH>);
close(FH);
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to