in reply to Subroutine Produces Output but Fails to Return to Parent

It's hard to judge from your incomplete code excerpt what went wrong.
It partly works for me though.

Some remarks:

#build a dynamic sql statement my $Sql_str = &BuildSQLString($cMssFactBag); print $Sql_str; #I print here I get no SQL statement

So far, it looks not too bad, except that you shouldn't be using an ampersand (&) here, unless you know how it alters the behaviour of the subroutine called (circumvents prototypes; without arguments being called, also passes @_ implicitly)

sub BuildSQLString { ... $dynam_Sql_stmt = join(" ",$dynam_Sql_stmt, "from $p_str_tblName where + RECORDXFEREDTOFILE = 'I'"); #I print here I a SQL statement return $dynam_Sql_stmt; }

Where do $p_str_tblName, $dynam_Sql_stmt come into life? May we see what ... stands for?

A few related hints:

  • The scoping of some variables is inadequate (see my, local & our)
  • The arguments weren't properly passed to or received by the subroutine (see perlsub)
  • There's a spelling error lurking somewhere (can be caught by strict)

    However, I recommend to enable strict & warnings in most circumstances.

  • Replies are listed 'Best First'.
    Re^2: Subroutine Produces Output but Fails to Return to Parent
    by vegasjoe (Sexton) on Jan 18, 2007 at 23:40 UTC
      I am turning on strict and will use warnings. I will also remove the & before calling the build sql function. Thank you for the responses.