<?xml version="1.0" encoding="windows-1252"?>
<node id="1004499" title="Re: Program unexpectedly terminates" created="2012-11-19 04:29:56" updated="2012-11-19 04:29:56">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;It would be helpful if the sample code you provided actually compiled (undefined &lt;c&gt;$class&lt;/c&gt;, &lt;c&gt;%args&lt;/c&gt; and &lt;c&gt;&amp;shuffle&lt;/c&gt; prevents compilation with strict subs/vars). Fixing those issues...&lt;/p&gt;

&lt;readmore&gt;&lt;code&gt;
#!/usr/bin/env perl
use 5.016;
use warnings;
use Carp::Always;

BEGIN { *CORE::GLOBAL::exit = sub { die("exit called") } }
END { say "END block"; }

my $crawler = Crawler-&gt;new;
$crawler-&gt;run;

die("finished");

package Crawler {
	use parent 'LWP::UserAgent';
	use List::Util qw(shuffle);

	sub new {
		my ($class, %args) = @_;
		my $self = $class-&gt;SUPER::new(%args);
		$self-&gt;{ids} = [1..100];
		return $self;
	}

	sub run {
		my $self = shift;
		my @idx = shuffle 0 .. -1 + @{ $self-&gt;{ids} };
		my $cur = 0;
		for my $i (@idx) {
			my $id = $self-&gt;{ids}[$i];
			printf "%d/%d: %s (%d)\n", ++$cur, 0+@idx, $id, $i;
			# Fetch and process stuff related to this id.
		}
	}

	sub DESTROY { say "Crawler destroyed" }
}
&lt;/code&gt;&lt;/readmore&gt;

&lt;p&gt;... the code seems to execute correctly here.&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1004479</field>
<field name="parent_node">
1004479</field>
</data>
</node>
