in reply to piping a function into a backtick shell
Update: Although if this weren't a one-off I'd create a class for this with a 'fetch' method that uses wantarray to distinguish between a call that wants the lot and one that wants to fetch only one line of result output at a time.use IPC::Open2; use POSIX ":sys_wait_h"; my @results = Sql( 'select ...' ); sub Sql { my $command = shift; my $options = ( shift() || '-qs' ) . ' -'; my $pid = open2 my $rh, my $wh, 'ac_bl ' . $options; write $wh $command; close $wh; my @results = <$rh>; chop @results; close $rh; waitpid $pid, 0; return @results; }
-M
Free your mind
|
|---|