in reply to Grabbing source table names from a SQL query

You could construct the filename at the moment you build the query, and pass it as a second argument to dumpResultsToFile():

my @tables = qw*TADA*; dumpResultsToFile ( <<" END_SQL", join('.', @tables) ); SELECT $tables[0].fileName, $tables[0].labelName FROM $tables[0] END_SQL sub dumpResultsToFile { my ( $query, $filename ) = @_; ... open my $fh, '>', "$filename.txt" or die

If you want a filename depending on tables, get the table names from their origin, i.e. where that information enters your program. Asking that information from some other module deep in the processing chain looks wrong to me, since you have it handy in the first place.

Replies are listed 'Best First'.
Re^2: Grabbing source table names from a SQL query
by PoorLuzer (Beadle) on Oct 22, 2009 at 02:20 UTC
    This is a really good answer. Focused on "Getting things done" than being pedantic. Would still love to know if grabbing query elemnst from a statement handle can work though.