in reply to Extracting data from a WireShark log
And here's one way to convert the saved data lines to bytes:...open LOGFILE... my (@list, %info); while (<LOGFILE>) { if (/^Frame /) { # detect start of new data record if (%info) { push(@list, { %info }) } # save last collected record %info = (); # start with blank record } elsif (/^ *Source port: (\S+)\s+(\S+)/) { $info{source_port} = $1; # also save $2? } elsif (/^ *Destination port: (\S+)\s+(\S+)/) { $info{dest_port} = $1; } elsif (/^[\da-f]{4}\s+[\da-f\s]+/i) { push(@{$info{data}}, $_); # save data lines } } if (%info) { # must check at end of loop push(@list, { %info }); } # @list contains parsed Frame records
my $bytes; for my $line (@{$info->{data}}) { if ($line =~ m/^[\da-f]{4}\s*(([\da-f]{2} )+)/i) { my $hex = $1; $hex =~ s/\s//g; $bytes .= pack("H*", $hex); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Better scoping for the hash: was Re^2: Extracting data from a WireShark log
by Narveson (Chaplain) on Apr 29, 2008 at 18:13 UTC |