in reply to database query with POE::Wheel::Run
Looking at the relevant part of POE::Wheel::Run, it looks like the following:
# $program is what you pass in as the Program key # $progargs is the array reference of arguments else { if (ref($program) eq 'ARRAY') { exec(@$program, @$prog_args) or die "can't exec (@$program) in child pid $$: $!"; } else { exec(join(" ", $program, @$prog_args)) or die "can't exec ($program) in child pid $$: $!"; } }
So basically, your program gets run as one string, so you need to either supply the shell-safe quoting yourself (not so good idea) or avoid the shell alltogether by passing Program and ProgramArgs as array references (very good idea):
my $wheel = POE::Wheel::Run->new( Program => [ $program ], # changed! ProgramArgs => \@progargs, StdinEvent => 'stdin', StderrEvent => 'stderr', StdoutEvent => "stdout", StdoutFilter => POE::Filter::Stream->new(), );
should work, or the worse solution is to quote the program arguments twice:
$progargs = (q{"SELECT * FROM MY_TABLE;"});
See perlop for more about the q{} operator.
|
|---|