#!/usr/bin/perl -w use strict; use warnings; use WWW::Mechanize; use HTML::TreeBuilder; use List::Util qw(max); ... my $site = "http://www.hdwallpapers.in /planes-desktop- wallpapers.html"; $mech->get($site); my @links = map {$_->text} grep {$_->text =~ m/\d+/} $mech->find_all_links(); print max @links;