sub sub1 { my %enc; for (@_) { chomp; if ( $_[0] =~ /^ "xxxx-(\d+):xxxxxx([^,]+),.+"$/ ) { $enc{$1} = $2; } else { next; } } } %hash1 = sub1(@dc);