#!/usr/bin/perl -w use strict; my @fields = qw[Company Contact Title Phone]; for my $file (@ARGV) { open TEXT, "< $file" or die "Couldn't open $file: $!\n"; my %contact; while() { chomp; my ($k, $v) = split ": " or next; $contact{$k} = $v; } # hashslice print join("|", @contact{ @fields }), "\n"; }