Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Strict Ref : ERROR

by Sandy (Curate)
on Jun 28, 2006 at 17:44 UTC ( [id://558088]=note: print w/replies, xml ) Need Help??


in reply to Strict Ref : ERROR

In english, this is what your code does. I've included comments where I think that you are mistaken about what your code is actually doing.
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
I think you need to fix your algorithm first, then, once you have something that makes sense, convert it to perl.

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
    Thanks... I will fix things up. Helped me a lot.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://558088]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-25 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found