#! perl use strict; my $file = shift(@ARGV) || "foo.txt"; open(FH, $file) or die("Cannot read '$file': $!"); my @field_list = qw(put in reasonable names here for your data); while () { chomp; my %row; @row{@field_list} = split /\|/, $_; my ($field_data, $comment) = split /;/, $row{data}; print "$field_data\n"; }