use warnings; use strict; use Mojo::DOM; my $html = <<'END_HTML'; a b c END_HTML my $dom = Mojo::DOM->new($html); my $spans = $dom->find('span[class~="D(ib)"]')->each( sub { print "==> $_ <==\n" } ); __END__ ==> a <== ==> c <==