open IN, 'db.txt' or die "cannot open db.txt for input: $!\n"; while( ) { chomp; my @fields = split '|'; ... } close IN;