It would be helpful if the sample code you provided actually compiled (undefined $class, %args and &shuffle prevents compilation with strict subs/vars). Fixing those issues...
#!/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->new; $crawler->run; die("finished"); package Crawler { use parent 'LWP::UserAgent'; use List::Util qw(shuffle); sub new { my ($class, %args) = @_; my $self = $class->SUPER::new(%args); $self->{ids} = [1..100]; return $self; } sub run { my $self = shift; my @idx = shuffle 0 .. -1 + @{ $self->{ids} }; my $cur = 0; for my $i (@idx) { my $id = $self->{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" } }
... the code seems to execute correctly here.
In reply to Re: Program unexpectedly terminates
by tobyink
in thread Program unexpectedly terminates
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |