sub unfoldauthors { my ($data_ar) = @_; return unless ($data_ar); $data_ar = $data_ar->[0]; # die Dumper $data_ar; my @paths = qw( $..family $..given $..affiliation ); my @selectors; for my $p (@paths) { push @selectors, JSON::Path->new($p); } my $aff_name = JSON::Path->new('$..name'); my $name; my @lines; my @sep = ( ", ", "; ", " " ); my $col = 0; for my $s (@selectors) { my @text = $s->values($data_ar); #print $col, " ", Dumper(@text), "\n"; my $authors_limit = 50; my $last = $authors_limit - 1; if ( @text > $authors_limit ) { @text = @text[ 0 .. $last ]; $text[$last] .= " ..." if ( $col == 1 ); } my $pos = 0; for my $name (@text) { #print "$col $name\n"; if ( $col == 2 ) { my @aff = $aff_name->values( $text[$pos] ); #print "aff:", Dumper( @aff ), "\n"; $name = join( " - ", @aff ); #print "\$name $name\n"; } $lines[ $pos++ ] .= $name . $sep[$col]; } $col++; } return \@lines; }