perl - Print data after dumper -


i have structure data-dumper:

$var1 = {       'field' => [                  {                    'content' => {                                 'en' => [                                         'footware haberdashery leather goods'                                       ],                                 'de' => [                                         'schuhe kurzwaren und lederartikel'                                       ],                                 'it' => [                                         'calzature mercerie e pelletterie'                                       ]                               },                    'type' => 'tag',                    'valore' => 'tag3'                  },                  {                    'content' => {                                 'en' => [                                         'cobbler'                                       ],                                 'de' => [                                         'schuster'                                       ],                                 'it' => [                                         'calzolai'                                       ]                               },                    'type' => 'tag',                    'valore' => 'tag24'                  }                ]     }; 

my question is: how take data , print 1 one ? want print name, tag , valore. software necessary take name of shop , more data example type

it looks structure hashref containing arrayref of hashes, , on. , apparently mention 'name' mean 'content' language. likewise, seems mention 'tag' mean 'type'. answer based on assumptions.

foreach $rec (@{$href->{field}}) {     print "$rec->{content}->{en}->[0]: $rec->{type}, $rec->{valore}\n"; } 

the -> between {content} , {en}, , again between {en} , [0] optional, , matter of style.

if want access elements directly (foregoing loop), might this:

print $href->{field}->[0]->{content}->{en}->[0], "\n"; print $href->{field}->[0]->{type}, "\n"; print $href->{field}->[0]->{valore}, "\n"; 

if want print all languages, this:

foreach $rec (@{$href->{field}}) {     print $rec->{content}->{$_}->[0], "\n" foreach sort keys %{$rec->{content}};     print $rec->{type}, "\n";     print $rec->{valor}, "\n\n"; } 

there several perl documentation pages of use in future learn manipulate references , datastructures perl: perlreftut, perlref, , perldsc. access them own system perldoc perlreftut, example.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -