#!/perl use strict; use warnings FATAL => qw(all); use Encode; use FindBin qw($Bin); use lib $Bin; use testlib; use Try::Tiny; my $path = shift or die "No source!\n"; my $string = do { local $/ = undef; open my $in, "<", "$path" or die "$!";<$in>;}; my $xml = decode('utf8', $string); my $h = House->new(xml => $xml); for my $d ( @{$h->depts} ) { for my $art ( @{$d->articles} ) { my $prod = try {$art->prod} catch {0}; # $art->prod // 0; my $country = $prod ? $prod->country : ''; print join("\t", $d->name, $art->key, $country), $/; } }