in reply to Returning variable from sub

One tiny point - the correct English spelling of derived is <---. Unless you mean something else, of course.

You might also want to think about:

use strict; use warnings;

If I don't say it, someone else is bound to ;-) See docs for strict and warnings.