use Data::Dumper; $hash{bing} = 'bang'; for (qw/fooXbar bishXbash/) { @_ = split /X/, $_; $hash{$_[0]} = $_[1]; } print Dumper(\%hash);