my( $ip, $date, @data ); my $seen_time_address_header = undef; while( ) { if( /address (\d+\.\d+\.\d+\.\d+\(.*\))/ ) { $ip = $1; } if( /Logins for (\S+)/ ) { $date = $1; } if( /^\s+Time\s+Address/ ) { $seen_time_address_header = 1; } if( $seen_time_address_header and /((?:\d+\.?){3})\s+(\S+)/ ) { push @data, [ $1, $2 ]; } }