#!/usr/bin/perl use strict; use warnings; use Mojo::DOM; use feature 'say'; # slurp from file, get from a live site via Mojolicious::UserAgent etc... # hardcoded for example purposes my $html = '

example.com

'; my $dom = Mojo::DOM->new( $html ); for my $url ( $dom->find('a[href^=";widget=460"]')->each ){ $url->attr('href' => 'https://perlmonks.org'); } say $dom->content;