Look at example 32 in the Inform documentation, Gopher-Wood:
The Ark is a room. A bearded man is in the Ark.
Instead of examining the bearded man for the first time:
now the printed name of the bearded man is “Japheth”;
now the bearded man is proper-named;
say “You peer at him a bit more closely and realize that it’s Japheth.”
[Finally, we need to tell Inform to understand the man’s name, but only when he’s been introduced. For this purpose, we borrow from the chapter on Understanding:]
Understand “Japheth” as the bearded man when the bearded man is proper-named.
Test me with “x japheth / x man / look / x japheth”.[/code]
In your case, if he’s proper-named to begin with, you don’t need to change that; but you would need to change the Understand line to catch the correct condition. Also, note that the name of the action is “examining,” not “looking at”; there can be many different commands that lead to an action, but there’s only one name for the action that you can use in source code. So the action that LOOK AT MAN and EXAMINE MAN trigger must be described in the source code as “examining John.”
…oh, and you’re using “Before looking at John” to do something that kind of thing doesn’t do. A “Before” rule will say something that happens before you perform a certain action–so if you write a “Before examining John:” rule it will take effect when the player types “x John,” just before the examining happens. If you want John’s printed name to be “anonymouse” until John is examined, just set it that way at the beginning:
The printed name of John is "anonymouse".
And then make sure it can be understood properly:
Understand "anonymouse" as John.
In this case you don’t need any extra code to get the game to understand “John,” because it will automatically understand his name as referring to him unless you make him privately-named.
(Also, “anonymous” is spelled with no e, though I’m not sure if you’re making a pun.)