Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-05-23 16:00 GMT
Find Nodes?
    Voting Booth?