That's easy enough. Try something like this:
open(INFILE,"zoo.txt"); @animals = <INFILE>; Perl will automatically dump the entire contents of the file into the array, with each line as an element. But beware! If you try to do this with extremely large files, you can really bog down your program. In many cases it's better to loop through the file line by line using the "while(<INFILE>){" syntax. Note: If you don't want the "\n" character at the end of each line to show up in your variables, you should also do a "chomp(@array)". -----Original Message----- From: Ashutosh Jog [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 27, 2002 10:09 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Newbie Question. Hello, This might be a very simple question, but being a newbie I have to ask. :) How can I copy the line by line contents of a file to a array? For eg: @animals should look like @animals = ('tiger','lion','elephant'); And the text file would have entries for the same in this order (i.e. one after the other): tiger lion elephant Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]