in reply to Grabbing url from iframe

A quick survey of your recent posts suggests that your mindset about PM is reflected in your request, "Can you give me some code (emphasis supplied) for either or both of these?"

While most are not quite such blatant 'gimmes' (which richly deserve the first part of wjw's answer) you don't seem to have internalized the notion that Monks are more than willing to help with specific issues, we prefer to see that the requestor has made some effort -- in other words, shows some code, research results or the like -- that evidence a good faith effort to solve your problem.

So please, read (and heed) On asking for help and the other basic guidance provided on the norms of the Monastery.

As to your current request: that's not a Perl issue; that's basic arithmetic:

320  =  x
560     349

All you need to do is write code to handle that kind of equation.

updated: Minor rephrasing. markup fixed