open(DAT,$data_file) || die "Couldn't open file": foreach() { chomp; my($son,$father) = split; $fathers{$son} = $father; } close(DAT); my $son = 1045316419; my $father = $fathers{$son}; my $grandfather = $fathers{$father};