On 6/8/07, Martin Barth <[EMAIL PROTECTED]> wrote:
Hi,

> I know that using 'Here Documents', we can output multiple lines. But is it
> possible to run a couple of commands?
>
> $s = qx [sqlplus user/[EMAIL PROTECTED] <<ENDOFSQL
> select 2 from DUAL;
> exit
> ENDOFSQL];

what do you think about that:

open(DBI, "| sqlplus user/[EMAIL PROTECTED]");
then print DBI with a Here Document?

that should work, shouldn't it?

Martin's idea seems the way to go. You can abstract it via

sub sqlplus {
      my $param = shift;
      my $script_text = shift;
      open my $script, "| sqlplus $param" or die $!;
      print $script $script_text;
      close $script or die $!;
}

sqlplus("user/[EMAIL PROTECTED]", <<SCRIPT );
select 2 from DUAL;
exit
SCRIPT

Another implementation could use File::Temp.


sub sqlplus {
      my $param = shift;
      my $script_text = shift;
      require File::Temp;
      my ($fh, $filename) = File::Temp::tempfile;
      print $fh $script_text;
      close $fh;
      system "sqlplus $param [EMAIL PROTECTED]"
}

(untested)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to