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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading an array

Status
Not open for further replies.

Flipster

MIS
Jun 25, 2001
38
0
0
US
If I have a file containing a single string on each line, how would I load all of the strings into an array?

I was mistaken in believing that you can just ...

@array = file

but that only loads the name of the file. Any help would be appreciated.
 
You have to open the file like this:

open(F, $File) or die "Can't open $File: $!\n";
@Array = <F>;
close(F);
 
You would also do well to remember that you'll have &quot;\n&quot; at the end of each string so remeber to chomp!!!
 
Oh, I chomp with the best of 'em. Thanks, though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top