in reply to create module using perl
You might actually want to read perlsub first, as the first step to converting your code to a module would be to create a subroutine.