|XP is just a number|
There is a Firefox extension, WebDeveloper. It has one menu item, outline current element. It shows position of element. Example:Firstly, please note that that is not a unique position. If you want to be able to find what was selected/clicked later, you need to use an XPath-like notation; something like:"html > body #id-479 > center > table > tbody > tr > td .main_content > form > table > tbody > tr > td > ul"for an element in this page.
"html > body#id-479 > center > table > tbody  > tr > td.main_content > form > table > tbody > tr > td > ul"
And that's just the content-targeting part. The remainder is communicating the "path" string to your perl back-end via AJAX (XMLHttpRequest, etc).
I see that like YourMother, I assumed you'd want to remember the XPath-like position in order to translate it to a (browser-relative) pixel-position.
If that's not the case, then you can start with something like YourMother has written below (using jquery, or some other library that smooths over browser differences).
To be accurate, you will need to form an XPath-like expression, so why not use real XPath?
There's a cross-platform library available here.
To construct the XPath expression, you'll have to walk up the DOM from the target element to the document.body (root). At each level, you'll need to determine 'id', 'class' and sibling-rank (with that selection priority).