in reply to Strict Ref : ERROR
I think you need to fix your algorithm first, then, once you have something that makes sense, convert it to perl.LOOP1: 1.0 Read one line of data from log file and store in symbol $_ 2.0 Create an array of simple strings by splitting the string stored in $_ wherever there is a comma. Store this array in @values. NOTE: Each element of @values is a SINGLE string, not an array. 3.0 Connect to database NOTE: This will connect you to the database everytime you read a line from your log file because it is inside the loop that reads your log file! LOOP2: 3.1 Process each element of the array @values. 3.2 If this element is 'stop' then 3.2.1 Create sql statement. But you are using @values[0]. What does this mean? Each element of @values is a simple string. Did you only want that string, or did you expect that @values = ([array],[array]...) ??? 3.2.2 Preparing the sql statement. 3.2.3 Bind parameters to $_->[i] ??? But $_ is simply the single line of data that you read from your log file. It's a single string! Why do you expect it to be an array? 3.2.4 Execute db query 3.2.5 Rollback if error 3.2.6 Disconnect from database ... MISSING CODE.... 3.3 End of is current element of @values equal to string 'stop'? 3.4 Go back to LOOP2 to process more elements of the array @values (until all done) 4.0 Go back to LOOP1 to read next line of LOG file
At this stage, your algorithm is so mangled that it is not really a 'perl' problem. Perl is doing exactly what you are telling it to do, and then get's lost when you want an array from something that is not an array.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strict Ref : ERROR
by swetashah23 (Initiate) on Jun 28, 2006 at 17:50 UTC |