#!/usr/bin/perl -wT use strict; open LOG, "messages.txt" or die "Can't open file: $!"; while () { chomp; my @attributes = split /\|/; for my $attribute (@attributes) { print $attribute, "\n"; # or do whatever here } } close LOG;