In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Todd Wade) writes:
>
>"Gary Stainburn" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> 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)?
>> >
><snip />
>>
>> 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);
>> -- 
>
>or simply:
>
>print <FH>;

Reasonable for short files, wastes memory for big ones.  This file
opening looks like too much work.  I prefer:

{
  local @ARGV = "/location/of/header.incl";
  print while <>;
}

-- 
Peter Scott
http://www.perldebugged.com

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

Reply via email to