return sort
sub all_authors { my %authors; foreach my $book (@_) { $authors{$_}++ foreach $book->authors; } my @result = sort keys %authors; return @result; } say "Total unique authors: " . all_authors(@books);
Total unique authors: 4
sub all_authors { my %authors; foreach my $book (@_) { $authors{$_}++ foreach $book->authors; } my @result = sort keys %authors; return @result; } say "Total unique authors: " . all_authors(@books);
Total unique authors: 4