我是 perl 新手,我们有一个类似于以下的日志文件:
SQL> @D:\Luntbuild_Testing\ASCMPK\Files\MAIN\DATABASE\HOST\FILES\DDL\20120412_152632__1_CLTM_EVENT_ACC_ROLE_BLOCK.DDL
SQL> CREATE TABLE CLTM_EVENT_ACC_ROLE_BLOCK
2 (
3 EVENT_CODE VARCHAR2(4) ,
4 ACC_ROLE VARCHAR2(20)
5 )
6 ;
CREATE TABLE CLTM_EVENT_ACC_ROLE_BLOCK
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
SQL> @D:\Luntbuild_Testing\ASCMPK\Files\MAIN\DATABASE\HOST\FILES\DDL\20120412_173845__2_CLTM_EVENT_ACC_ROLE_BLOCK.DDL
SQL> DROP TABLE CLTM_EVENT_ACC_ROLE_BLOCK;
Table dropped.
现在我需要一个脚本来只显示有 ORA-XXX 错误的脚本路径,脚本应该只显示与 ORA-xxx 错误相关的 SQL> @D:\Luntbuild_Testing\ 的路径,我在下面尝试过,你能帮帮我吗加强同样的。
$file = 'c:\data.txt';
open(txt, $file);
while($line = <txt>) {
print "$line" if $line =~ /> @/; #here i want the output to display the path of the script with only ORA-xxx errors and ignore if there are no errors
print "$line" if $line =~ /ORA-/;
}
close(txt);