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

Ok that was a very helpful. I've updated my sub and call like so
sub process(){ my $processed = $_[0]; return sub { if ( @_ ){ print "Sub Process called\n"; my ($colname,$colval) = @_; $colval =~ s/^&//; # strip leading & - this only occurs in + the 'ADDITIONAL field' print "Colname: $colname\n"; print "Colvalue: $colval\n"; # detect ADDITIONAL with multiple key value pairs. if ( index($colval,'&') >= 0 ){ print "$colval contaisn & character - so it's the ADDI +TIONAL field with multiple key value pairs"; my @additional = split('&',$colval); foreach my $addval (@additional){ print "additional has pair: $addval\n"; my @addpair = split('=',$addval); print "$addpair[0] | $addpair[1]\n"; process->($addpair[0], $addpair[1]); # this doesn' +t get called. } } # detect ors if ( index($colval,'|') >= 0 ){ print "$colval contains pipe character for ORs"; } # detect wildcards if ( index($colval,'*') >= 0 ){ print "$colval contains whidcard character"; } } } }

Calling it now like
process->("TABLENAME",$TABLENAME) if defined($TABLENAME);

But, now that I'm calling split for each additional key/value pair in the additional column, I see the values get displayed by the print statement, but the sub doesn't get called.