in reply to Re: Referencing a Backreference
in thread Referencing a Backreference

put the ip in a variable.
Update:The error was actually in the original regex given not properly matching the names, as far as I can tell, but i think it's much more readable to use a variable name instead of $1, which I think looks confusing and non-intuitive inside of a pattern match.
#!/usr/bin/perl -w use strict; my @addrs = ( "192.168.89.1 acmeorp.acme.com", "192.168.31.3 ftp.acme.com", "192.168.19.179 [Unknown]" ); my (@ips,@names); for (@addrs) { push (@ips, $1) if /\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b/; my $ip = $1; push (@names, $1) if /\Q$ip\E\s+([\w.]+[^\s]*$|\[Unknown\])\s*?/; } print @names;