%author = map { /^\d{6}$/ ? $_ : [ split( /\|/, $_, 2 ) ] } map { split( /=/, $_, 2 ) } grep { /^\d{6}=[^|]+\|/ } ; #### my %author; while () { next unless /^\d{6}=[^|]+\|/; my($l, $r) = split /=/, $_, 2; $author{$l} = [ split /\|/, $r, 2 ]; } #### my %author; while () { next unless /^(\d{6})=([^|]+?)\|(.*)/; $author{$1} = [ $2, $3 ]; }