in reply to Regex / "Sophisticated" End of Line

It's easier to read/modify/extend if you separate your matching requirements, rather than a convoluted look behind or look ahead expression...untested
if($line=~/Homo sapiens/) { if($line=~/((NP_|XP_))([^ ]+)/) { $matched=$1 . $2; ...do other stuff... } }
or similar
the hardest line to type correctly is: stty erase ^H