in reply to Push to Reference
It would be best if you could reduce your code down to only what is relevant to the question, so e.g. replace gethostbyaddr and those regexes by test data (see SSCCE). Also, you're using the Data::Dumper variable names VAR1, VAR2, etc., but haven't shown the call to Dumper(...), so we don't know which original variables those are. Anyway, based on your desired output, I am guessing that you want an "array of hashes", but your %targets is instead currently a "hash of arrays". It would probably be best if you read perlreftut and perldsc, the latter contains example code for both types of data structure.
use Data::Dumper; my @targets; push @targets, { _source=>"s1", _name=>"n1" }; push @targets, { _source=>"s2", _name=>"n2" }; print Dumper(\@targets); __END__ $VAR1 = [ { '_source' => 's1', '_name' => 'n1' }, { '_name' => 'n2', '_source' => 's2' } ];
|
|---|