well,

i was messing around with implementing some security into my program and i noticed some strange thing in one of my foreach loops

foreach (@array){ do something $self->_call($_); do something else }
if the number of arguments were higher than 50 in @array the foreach skipped all the variables over it. if the $_ argument was very complex then the limit was 20 arguments. so my question now is: is it possible that foreach will loop not waiting for the object (_call()) to finish and just go on. because if it is, then i have a serious problem. my program through time build up to huge number of lines and huge number of number of foreach loops.

if this is the case then please help me with some quick fix.

thnx

PS

it is interesting that i always stumble over some basic stuff, did anyone noticed the same problem (stumbling over basics while at the same time writing solutions to a really hardcore stuff)?

UPDATE:

ok what happens is this:

sub _do { my ($self,%arg) = @_; unless(%arg){ # some stuff (~200 lines) foreach my $choice (@array_choices){ # + log update my @choice_array = split(",",$print_hash{$choice}); my $pick; ($choice_array[0] eq 'correct') ? ($pick = "$choice_array[1]-$ +choice_array[2]") : ($pick = $choice_array[1]); # pick for correctio +n $self->_do($choice_array[0] => $pick); + # repete undo precedure with defined values ($choice_array[0] eq 'correct') ? (delete $class_log{do}[$hash +_order{$choice_array[0]}]) : (delete $class_log{do}[$hash_order{$prin +t_hash{$choice}}]); # delete do choice push(@return_log,"_do($choice_array[0] => $choice_array[1]);") + unless (ref $pick eq 'ARRAY'); # data for physh push(@return_log,"_do($choice_array[0] => \[$choice_array[1],$ +choice_array[2]\]);") if (ref $pick eq 'ARRAY');# data for physh } } else{ # brute _do } }
so what happens is ido something and then use the loop to automatically delete the data from the array instead of writing another loop to do that

so the answer to grizzley's second question is yes my mistake both answers are no (at least it seams for now, let me check again)

also the sub uses some ~100 other objects in the first part is the sub (it is a final wrapper) so showing you the whole script won't do any good

UPDATE2:

the loop and objects called within the loop are "redo,last" free, no such calls are made


In reply to foreach loop - could it beeeeee!! by baxy77bax

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.