[ale] Invalid value for share scalar?

Christopher Fowler cfowler at outpostsentinel.com
Mon Oct 2 10:13:16 EDT 2006


I'm playing around with Net::Pcap and I've written a program that will
capture packets and push those packets to a list (array).  A thread will
then process that list.  

Here are some pieces:

     12 {
     13   package Packet;
     14 
     15   sub new {
     16     shift;
     17     my ($v1, $v2)  = @_;
     18     my $Packet = {
     19     "timestamp" => $v1,
     20     "packet"    => $v2,
     21     };
     22 
     23     bless $Packet, 'Packet';   
     24     return $Packet;               
     25   }
     26 
     27   sub get_packet {
     28     my $self = shift;
     29     return $self->{'packet'};
     30   }
     31 
     32   sub get_timestamp {
     33     my $self = shift;
     34     return $self->{'timestamp'};
     35   }
     36 
     37 }
     38 
     39 my @objs  : shared = ();
     40 

...

    105 sub catch {
    106   my ($arg,$hdr,$pkt) = @_ ;
    107   push @objs, Packet->new(now(), $pkt);
    108 }


Here is the error I'm getting:
Invalid value for shared scalar at ./syn.pl line 106.
Can someone tell me what I did wrong?  

The whole idea of the thread is that I want the packets logged.
Eventually to a database.  I need the capture thread to do nothing but
read data from the device as fast as possible.  The processing thread
can take its sweet time going through the results.


Thanks,
Chris






More information about the Ale mailing list