#!/usr/bin/perl -w use strict; while () { if (m/Client Address = ([0-9.]+)\s*$/) { my $ip_adr = $1; my $units_rcvd = get_units_rcvd(); print "$ip_adr => $units_rcvd\n"; } } sub get_units_rcvd { while () { if (/Data Units Received = ([0-9]+)\s*$/) { return ( $1); } } } =prints: 192.0.0.6 => 260 192.0.0.4 => 351 192.0.0.5 => 207 192.0.0.2 => 401 192.0.0.3 => 340 =cut