BBBBB 01/08/2018 # is nested inside the table
236002121 266
#### use strict; use warnings; use Mojo::DOM; use Data::Dumper; use feature qw/say/; my $input = join '', map { $_ } ; my $dom = Mojo::DOM->new($input); my @results; for my $h3 ($dom->find('h3')->each) { # skip everything but the heading we are after next unless $h3->all_text =~ /^\s* BBBBB \s+/ix; # assume that immediately after the heading we have the table we are interested in my $table = $h3->following->first; $table->find('td')->each( sub { push @results, $_->all_text} ); } say Dumper \@results; __DATA__

AAA 28/07/2018

1351990783523

BBBBB 01/08/2018

236002121266

KK K P 25/07/2018

2003345667137