Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Program unexpectedly terminates

by tobyink (Abbot)
on Nov 19, 2012 at 09:29 UTC ( #1004499=note: print w/replies, xml ) Need Help??

in reply to Program unexpectedly terminates

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.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Program unexpectedly terminates
by Anonymous Monk on Nov 19, 2012 at 09:35 UTC
    Thanks for the helpful contribution Mr. Pedantic :-P

      Thank you for providing code that neither compiles nor illustrates your problem Mr Anonymous.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004499]
and the monastery is silent...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2017-03-27 02:10 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.