Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open File

Status
Not open for further replies.

milage

Programmer
Jul 13, 2001
58
US
Hi,

I need to read in all the contents of a file.

I have got this far.

open(afile, &quot;<filename>&quot;) or die &quot;&quot;;
read(afile, my $buffer, 1000) or die &quot;&quot;;
close afile;

However, I don't want to just read in 1000 I want to read in the all the contents of the file.

How would I do this?

Cheers

Rob
 
Like this:

[tt]
open(FILE,&quot;filename.txt&quot;) or die &quot;Failed to open file: $!&quot;;
@contents = <FILE>;
close(FILE);
[/tt]

Then you can do whatever you wish with @contents.

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top