my %publications = $tree->look_down( _tag => 'span'); open my $fh , "<", $tree->as_HTML; while (<$fh>) { my $author; next unless ($_ =~ /(?:span|li)/; $_ =~ /span/ ? $author =~ /\>(.+)\<\/span/ : push @publications{$author}, /li\>(.+)\<\/li/; }