For what it's worth, I just tried abusing my laptop with this code:
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";
With the undef in place, the difference between the "Start" and "Finish" times was 15 seconds. With the undef commented out, the difference between "Start" and "Finish" was only a little over a minute (1:04); however, five minutes after printing the "Finish" line my laptop was still swapping like mad and the shell prompt hadn't yet come back - this indicates that perl was having a devil of a time cleaning things up on exit. (I just gave up and hit Ctrl-C at that point)

Incidentally, while the version without an undef was running, it took a full 30 seconds for my laptop to display the Ctrl-Alt-Del screen after I gave it the three-finger salute.

I'm not going to try the 16_000_000 times I suggested above.


In reply to Re: Re: Q on HTML::Element recursive lambda comment by fizbin
in thread Q on HTML::Element recursive lambda comment by lucylane

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.