in reply to How to use matched strings

can you use something like below for the purpose ? open (USERANDIP,"<userandip") or die "Cannot open ip file $!\n"; open ( USERNAME , "<username" ) or die "Cannot open user file $!\n"; @ip = <USERANDIP>; while (<USERNAME>){ $user = $_ ; @result = grep (/$user/,@ip); print "@result" ; }