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.


In reply to Re: Strict Ref : ERROR by Sandy
in thread Strict Ref : ERROR by swetashah23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.