#!/usr/bin/perl
$s = qx{sqlplus -s "/ as sysdba" <<EOF
set head off
select * from dba_tables where rownum<5;
exit
EOF };
@lines = split /\n/, $s;
for ($i = 0; $i < scalar @lines; $i++)
{ print "This is line $i: $lines[$i].\n";
}
this script is working right, but if I will change the table name to v$controlfile will get error message:
#!/usr/bin/perl
$ctlfiles="select name from v\$controlfile";
$s = qx{sqlplus -s "/ as sysdba" <<EOF
set head off;
$ctlfiles;
exit
EOF };
@lines = split /\n/, $s;
for ($i = 0; $i < scalar @lines; $i++)
{ print "This is line $i: $lines[$i].\n";
}
output:
This is line 0: select name from v.
This is line 1: *.
This is line 2: ERROR at line 1:.
This is line 3: ORA-00942: table or view does not exist.