in reply to substitute with sub result?

For one, you need s/.../.../eg.  The e makes the substitution part be treated as Perl code.

Then, it should also be my $number = shift;  (use strict; would've told you... :)