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
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).use strict; use warnings;
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
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) isforeach(@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);}
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?foreach(@sof_i) { $sof_to_delete++; } shift @sof_i for (0..$sof_to_delete)
In reply to Re: Array undefining istelf?
by Grygonos
in thread Array undefining istelf?
by K_M_McMahon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |