Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Program unexpectedly terminates

by tobyink (Canon)
on Nov 19, 2012 at 09:29 UTC ( [id://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'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1004499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found