I see no my's in your code so i'm going to venture to say you're not using strict here. I would add

use strict; use warnings;
to the top of the script and see what develops. It also seems that you are not passing any parameters to your subs and using global variables instead. Passing references to your variables into your subroutine makes your code a little more understandable (because you know what data you will be working due to explicitly passing references to the subroutine).

I'm not trying to be dismissive of your question at all.. but using strict pragma can reveal so many problems you didn't even know existed in your code. If you're serious about learning more perl and becoming exceedingly efficient at coding and debugging it.. then I would strongly reccomend using strict.

Put the strict and warnings after your shebang and correct the errors it displays, then you may have a clearer picture of what's going on in the program. This whole problem could be as simple as mispelling a variable in one place of the program.

This piece of code

foreach(@sof_i) { last if $_=~/^={30}/; ($i_day, $i_month, $i_date, $i_hour, $i_minute, $i_second, $i_ +year)=$_=~/(^\D{3}) (\D{3})\s+(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4 +}) sw_eof \[.+\] try / if $_=~m/try/; ($i_con_day, $i_con_month, $i_con_date, $i_con_hour, $i_con_mi +nute, $i_con_second, $i_con_year)=$_=~/(^\D{3}) (\D{3})\s+(\d{1,2}) ( +\d{2}):(\d{2}):(\d{2}) (\d{4}) sw_eof \[.+\]/ if $_=~m/connected/; ($i_socket_status)=$_=~/\[(.*)\]/ if $_=~m/EOF Socket Status/; $sof_to_delete++ } ##This just randomly deletes the first elements of the array for ho +wever many times you did $sof_to_delete++ for ($i=0;$sof_to_delete>0;$sof_to_delete--) {shift(@sof_i);}
confuses me. Of corse your array @sof_i will be empty.. you don't have a condition around $soft_to_delete++; so effectively what your code is doing (unless i'm totally crazy) is
foreach(@sof_i) { $sof_to_delete++; } shift @sof_i for (0..$sof_to_delete)
In turn looping through every value .. doing some regex and then marking it for deletion and then in fact deleting it..,

am I way off base here?

Grygonos

In reply to Re: Array undefining istelf? by Grygonos
in thread Array undefining istelf? by K_M_McMahon

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.