2

I am trying to execute user created Perl script,

usage: my.pl <type> <stats> [-map <map>] <session1> [session2] 
Produces statistics about the session from a Wireshark .pcap file where:
<type> is the type of data in the pcap file (wlan, ethernet or ip)
<stats> is the output file to write notable information
<session> is the pcap input file or a folder containing pcaps (recursive)

but it fails with the error below.

        $perl my.pl ethernet pa.xls google.pcap
        Processing pcap trace (TCP):
        Not a HASH reference at folder/httpTrace.pm line 654.

Here is the debug console -

    Not a HASH reference at folder/httpTrace.pm line 654. at folder/httpTrace.pm line 654
        folder::httpTrace.pm::readHttp('HASH(0x2306d38)', undef) called at my.pl line 56
        main::__processSession('google.pcap') called at my.pl line 35 Debugged program terminated.  

httpTrace.pm: last line# 654

    sub readHttp($@)
    {
        my ($conntable, $map) = @_;
        my $http_req_id = 0;
        my $pipelining = 0;

        my $mapc;
        my @allReq;
        my @allRep;
        if( defined( $map ) ) {
            $mapc = $map->clone();
        }
    foreach my $connect ( sort { $pa->{'id'} <=> $pb->{'id'} } values( %{ $conntable } ) ) {

line 56 in my.pl:

    my $stats = Pcapstats::HTTP::readHttp( \%tcp_stream, $map );

Also there map.pm & usage in my.pl as

    my $map;
    if( $ARGV[0] eq '-map' ) {
        shift( @ARGV );
        $map = Pcapstats::Map->new( shift( @ARGV ) );
    }
P P
  • 137
  • 3
  • 13
  • That does not sound a like dependency problem. Please provide a minimal, runnable demonstration of the problem. – ikegami Jul 23 '12 at 14:53
  • 2
    vote_to_close(1) unless( more_information_given('fast') ); – clt60 Jul 23 '12 at 14:54
  • vote_to_close(1); # It'll take him a while to come up with a proper question. He can start a new one then. – ikegami Jul 23 '12 at 14:57
  • @P P: already closed. You can open a new question, and don't need be hurry. Read and __follow__ http://stackoverflow.com/questions/how-to-ask . – clt60 Jul 23 '12 at 15:05
  • @jm666 can you reopen this question ? I have modified it. – P P Jul 23 '12 at 16:19
  • @ikegami cant you reopen this question, please ? Let me know if you need anything further ! – P P Jul 23 '12 at 18:41
  • You would have gotten more eyeballs by starting a new question rather than dredging up a zombie. Not to mention you wouldn't have all these unrelated comments around. Voted to reopen. – ikegami Jul 23 '12 at 19:09
  • Actually, I should have read your update first. It pretty much doesn't help anything at all. One of the values of %$conntable is not a hash reference. Just like the error messages says. There's nothing else we can do with what you gave us. – ikegami Jul 23 '12 at 19:11
  • Progress. `$map` is undef according to the stack trace. So find out why Pcapstats::Map returns undef. Well, that's assuming the code in the `if` was run at all. Make sure to check for that. – ikegami Jul 23 '12 at 19:49

1 Answers1

0

In your file httpTrace.pm you have this line

foreach my $connect ( sort { $pa->{'id'} <=> $pb->{'id'} } values( %{ $conntable } ) ) {

and I wonder what $pa and $pb are? Unless you have set them to something elsewhere they will be undefined and will give you Use of uninitialized value errors. Either way you will not be doing a sort.

But that doesn't explain the Not a HASH reference error, which is most likely because $conntable isn't what you think it is. It won't cause an error if it is undefined because autovivication will automatically create an empty hash, so it is probably a simple string or number, or possibly an array reference.

If you want to show the code that sets $conntable then we may be able to help further.

Borodin
  • 126,100
  • 9
  • 70
  • 144
  • can you help me out ? Yet I am not able to find out. I can provide more details if required. – P P Jul 24 '12 at 20:33