
phamou
Novice
Jun 17, 2008, 8:07 AM
Post #4 of 13
(1101 views)
|
|
Re: [meloyelo] Special Extraction requirement...
[In reply to]
|
Can't Post
|
|
I figured how to slurp the content of the file in one perl variable, Here is my code: #!/usr/local/bin/perl my $FilePath='file1.txt'; open(FileHandle, $FilePath) or die "Can't open $FilePath: $!"; ##########@lines = <FileHandle>; select((select(FileHandle), $/ = undef) [0]); my $content = <FileHandle>; close (FileHandle); while ($content =~ m/\{(.*?)\}\s*\{(.*)\}/sg) { print "execution time: $1\n"; print "sql statement: $2\n"; } #################print $content; #################print @lines; exit; Although, the WHILE loop doesn't work as expected.. only the first SQL Statement is returned, the rest of the file is returned as-is, here is a portion of the output ======================================================================================================================================== execution time: 00:00:00.004236 us sql statement: SELECT SW_Key_Nm, Config_Value FROM SW_Config c, SW_Key k, SW_Section s, SW_Object o WHERE c.SW_Object_Id=o.SW_Object_Id AND c.SW_Section_Id=s.SW_Section_Id AND c.SW_Key_Id=k.SW_Key_Id AND k.SW_Object_Id=o.SW_Object_Id AND k.SW_Section_Id=s.SW_Section_Id AND s.SW_Object_Id=o.SW_Object_Id AND s.SW_Section_Nm LIKE :1 AND o.SW_Object_Nm LIKE :2} [15:39:36.885] dal.oracle.connection Bindings: :1 char: ConfigDC (8) :2 char: Vend (4) [15:39:36.887] dal.connection_impl SQL: {00:00:00.002197 us} {SELECT SW_Key_Nm, Config_Value FROM SW_Config c, SW_Key k, SW_Section s, SW_Object o WHERE c.SW_Object_Id=o.SW_Object_Id AND c.SW_Section_Id=s.SW_Section_Id AND c.SW_Key_Id=k.SW_Key_Id AND k.SW_Object_Id=o.SW_Object_Id AND k.SW_Section_Id=s.SW_Section_Id AND s.SW_Object_Id=o.SW_Object_Id AND s.SW_Section_Nm LIKE :1 AND o.SW_Object_Nm LIKE :2} [15:39:36.942] dal.oracle.connection Bindings: :1 char: HT (2) [15:39:36.945] dal.connection_impl SQL: {00:00:00.054701 us} {SELECT Device_Id, Device_Nm FROM Device WHERE Device_Type_Cd=:1} [15:39:36.947] dal.oracle.connection Bindings: :1 long: 2 (4) :2 long: 1 (4) [15:39:36.949] dal.connection_impl SQL: {00:00:00.001932 us} {SELECT TL_Comm_IP, TL_Comm_Port, TL_Comm_Timeout, Connectivity_Status_Cd FROM Connectivity WHERE Host_Id=:1 AND Route_Seq_No=:2} [15:39:36.952] dal.connection_impl SQL: {00:00:00.001662 us} {SELECT COUNT(*) AS Total FROM NCR_Data_Collection} [15:39:36.977] dal.oracle.connection Bindings: :1 char: Encryption (10) :2 char: Vend (4) [15:39:36.979] dal.connection_impl SQL: {00:00:00.001861 us} {SELECT SW_Key_Nm, Config_Value FROM SW_Config c, SW_Key k, SW_Section s, SW_Object o WHERE c.SW_Object_Id=o.SW_Object_Id AND c.SW_Section_Id=s.SW_Section_Id AND c.SW_Key_Id=k.SW_Key_Id AND k.SW_Object_Id=o.SW_Object_Id AND k.SW_Section_Id=s.SW_Section_Id AND s.SW_Object_Id=o.SW_Object_Id AND s.SW_Section_Nm LIKE :1 AND o.SW_Object_Nm LIKE :2} ======================================================================================================================================== Please note that in the ORIGINAL text, there are spaces between the beggining of the line and "SQL:".. (if that helps..) Thanks alot for your help, Patrick
|