$_ = "client 127.0.0.1#47560: query: host.example.com IN AAAA +"; (my $ip) = /\s(.*?)#/; print $ip; #127.0.0.1