sub load_array { my $file = shift; # the first parameter is our file my @array; open(IN, $file) or die "Can't open $file: $!\n"; # for every line in the file... while() { chomp; # remove the trailing carriage return # could also be chomp $_; push @array; # put it into our array # could also be push @array, $_; } # while close(IN); return @array; } # load_array # to run this routine... my @array = &load_array("test.txt");