sub load_array($$) { #the first element we pass to this function is a #array reference, the second is the name of a file my ($a_ref, $file) = @_; #attempt to open the file or quit executing our program open (FILE, $file) or die "Can't open $file:$!\n"; #take all the lines in the file, and put them into the #array that $a_ref points to. @{$a_ref} = ; # close the file... duh I guess close FILE; # remove all of the carriage returns from the end of # each element in the array chomp @{$a_ref}; } # to call this routine my @array; &load_array(\@array, # pass in the reference to the array "test.txt"); # the name of our file