use strict;
use HTML::Element;
sub funny {
my $counter = 'x0000';
my $give_id;
$give_id = sub {
my $x = $_[0];
$x->attr('id', $counter++) unless defined $x->attr('id');
foreach my $c ($x->content_list) {
$give_id->($c) if ref $c; # ignore text nodes
}
};
$give_id->($_[0]);
undef $give_id; ##### Remove for evil effects #####
}
my $a = HTML::Element->new('a', href => 'http://www.perl.com/');
print "Start: ", scalar(localtime), "\n";
for my $i (0..1_000_000) { funny($a); }
print "Finish: ", scalar(localtime), "\n";