#!/usr/bin/perl -w
use strict;
my $line = 'client 127.0.0.1#47560: query: host.example.com IN AAAA';
my ( $part1) = split (/#/,$line);
my ( $ipaddr ) = (split(/\s+/, $part1))[1];
print " part1: $part1\n ipaddr: $ipaddr\n";
__END__
Prints:
part1: client 127.0.0.1
ipaddr: 127.0.0.1
####
(undef, my $ipaddr) = split(/\s+/, $part1);
####
my $line = 'client 127.0.0.1#47560: query: host.example.com IN AAAA';
(my $ipaddr) = (split/[\s#]/,$line)[1];
print "$ipaddr\n";
__END__
prints:
127.0.0.1