in reply to Re: Sub Routines and Building SQL statement
in thread Sub Routines and Building SQL statement

is this because I'm calling a sub within the defining sub?
  • Comment on Re^2: Sub Routines and Building SQL statement

Replies are listed 'Best First'.
Re^3: Sub Routines and Building SQL statement
by aaron_baugher (Curate) on Nov 21, 2011 at 21:14 UTC

    Sort of. The sub is getting run, or the print statement wouldn't be executed. But you're not doing quite what you're trying to do with the higher-order stuff. Your outer sub returns the inner sub, but you aren't assigning it to anything, just executing it. You never call it directly. So you might as well just use an ordinary subroutine.

    To return an inner sub and call it later, you do something like this:

    sub get_a_processor { # will return a reference to a sub that processes return sub { # your processing stuff } } my $processor = get_a_processor(); # $processor points to inner sub $processor->($TABNAME); #calls the inner sub on $TABNAME

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.