in reply to Extract the matching strings

You're nearly there. Instead of the comments, just do what the comments say:

# have to store the value of "YP_001648463.1" in $protname $protname = "YP_001648463.1";

If that's not quite what you're looking for, take a look at split.