TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
perl open file to array
Is there a way to open the content of a text file into a Array?
My text file is just one line of words with spaces:
name1 name2 name3
$DATA = "/home/lueyb/hostnames";
open(DATA, $DATA) || die "Could not open $DATA";
print <DATA>;
prints out the <DATA>, but I want to treat it as an array, so I can do
print "@DATA[1]\n";
etc.
Also, is there a way to have tables?
If my file is:
name1 name2 name3
stuff1 stuff2 stuff3
can I open it in perl a say
print "@DATA[2,2]\n";
to print stuff2 and 1,2 for name2, etc?
Thanks,
Ben
Ben Luey
lueyb@carleton.edu
ICQ: 19144397
It's only work if somebody makes you do it. -- Calvin