... $db = "textfile.txt"; open(DATA, $db) or die "cant open: $!\n"; @dat = ; close(DATA); foreach $line (@dat) { ... }