#!/usr/bin/perl use constant MAX_OPEN_CALLS => 100; use strict; use warnings; my $log = $ARGV[0] or die "Usage: $0 "; open(my $fh, '<', $log) or die "Unable to open '$log' for reading: $!"; my %call; { local $/ = '=============================================='; while (<$fh>) { my ($type, $id, $info) = parse_rec($_); if ($type eq 'INIT') { next if $info !~ /TCH/; die "Multiple calls with id '$id' without response" if exists $call{$id}; $call{$id} = undef; } elsif ($type eq 'RESPONSE') { next if ! exists $call{$id}; print "Call with id '$id' has a Px,Py of '$info'\n"; delete $call{$id}; } die "Too many unanswered calls" if keys %call > MAX_OPEN_CALLS; } } sub parse_rec { my ($rec) = @_; my ($type) = $rec =~ /CALL_(\w+)/; $type = '' if ! defined $type; my ($id) = $rec =~ /TRAN_ID\s+(\S+)/; my $info; if ($type eq 'INIT') { ($info) = $rec =~ /CHAN_TYPE\s+(\S+)/; } elsif ($type eq 'RESPONSE') { ($info) = $rec =~ /Px,Py\s*=\s*(\S+)/; } $info = '' if ! defined $info; return ($type, $id, $info); }