• Welcome to Valhalla Legends Archive.
 

Error in perl

Started by Krush[LM], January 17, 2005, 07:04 PM

Previous topic - Next topic

Krush[LM]

#15
Quote from: dyslexify on January 18, 2005, 08:13 AM

if ($byte == "\n")

that might work.
I haven't done any real perl work in quite a while, so my perl skills are rather rusty.

mb was right that didn't fix the problem

I think somehow the connection is becoming null at some point

Here is the function in IRC.pm getting the error:

# Goes through one iteration of the main event loop. Useful for integrating
# other event-based systems (Tk, etc.) with Net::IRC.
# Takes no args.
sub do_one_loop {
    my $self = shift;
   
    # -- #perl was here! --
    # <ChipDude> Pudge:  Do not become the enemy.
    #   <^Pudge> give in to the dark side, you knob.
   
    my ($ev, $sock, $time, $nexttimer, $timeout);
   
    # Check the queue for scheduled events to run.
   
    $time = time();             # no use calling time() all the time.
    $nexttimer = 0;
    foreach $ev ($self->queue) {
if ($self->{_queue}->{$ev}->[0] <= $time) {
    $self->{_queue}->{$ev}->[1]->
(@{$self->{_queue}->{$ev}}[2..$#{$self->{_queue}->{$ev}}]);
    delete $self->{_queue}->{$ev};
} else {
    $nexttimer = $self->{_queue}->{$ev}->[0]
if ($self->{_queue}->{$ev}->[0] < $nexttimer
    or not $nexttimer);
}
    }
   
    # Block until input arrives, then hand the filehandle over to the
    # user-supplied coderef. Look! It's a freezer full of government cheese!

    if ($nexttimer) {
$timeout = $nexttimer - $time < $self->{_timeout}
? $nexttimer - $time : $self->{_timeout};
    } else {
$timeout = $self->{_timeout};
    }
    foreach $ev (IO::Select->select($self->{_read},
    $self->{_write},
    $self->{_error},
    $timeout)) {
foreach $sock (@{$ev}) {
    my $conn = $self->{_connhash}->{$sock};
   
    # $conn->[0] is a code reference to a handler sub.
    # $conn->[1] is optionally an object which the
    #    handler sub may be a method of.
   
    $conn->[0]->($conn->[1] ? ($conn->[1], $sock) : $sock);
}
    }
}


More specific this loop:

foreach $sock (@{$ev}) {
    my $conn = $self->{_connhash}->{$sock};
   
    # $conn->[0] is a code reference to a handler sub.
    # $conn->[1] is optionally an object which the
    #    handler sub may be a method of.
   
    $conn->[0]->($conn->[1] ? ($conn->[1], $sock) : $sock);
}


at this line:

    # $conn->[0] is a code reference to a handler sub.
    # $conn->[1] is optionally an object which the
    #    handler sub may be a method of.
   
    $conn->[0]->($conn->[1] ? ($conn->[1], $sock) : $sock);


they mention $conn->
  • being "code reference to a handler sub

    and the error is :

    Can't use string ("") as a subroutine ref while "strict refs" in use at C:/Perl/site/lib/Net/IRC.pm line 150.


    that's why i'm saying that connection is becoming null but what would cause this?