#!/usr/bin/perl -w use strict; my @names; my @items; sub processRec { my $fh = shift; #ref to filehandle while(<$fh>) { chomp; s/\cM//; next if /^$/; next if /^\d-RECORD$/; push ( @names, /ITEMNAME-(.*)/); push ( @items, /ITEM \d-(.*)/); } } open( FH, "