#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Mojo::DOM; my $html = ' test

test heading

paragraph one one example.

paragraph two another example.

'; my $dom = Mojo::DOM->new( $html ); foreach my $e ( $dom->find('p > a')->each ){ say $e->{'href'}; } # or $dom->find('p > a')->each(sub { say $_->{'href'} } );