open(INPUT, 'file.txt') or die "Can't open file.txt: $!"; while () { chomp; my @data = split(/\|/, $_); # do something with @data } close INPUT;