in reply to Re^2: CGI: Passing variables to a subroutine
in thread CGI: Passing variables to a subroutine

You don't actually need to pass $ref_data as an argument to your subroutines, because they're already in its lexical scope. (They can "see" it already.)

But, it's good practice to keep the scope of things as small as possible, so why not just call create_data() in each of the subroutines where you need it? (Presumably, only one of them will be running per CGI request anyway.)

And I second the suggestion of using a dispatch table. There's also CGI::Application, which is like a dispatch table on steroids with all sorts of nifty OO stuff and plugins.