in reply to split split
You want the stuff between the first space and the first hash
$_ = "client 127.0.0.1#47560: query: host.example.com IN AAAA +"; (my $ip) = /\s(.*?)#/; print $ip; #127.0.0.1 [download]