Hello, I am having troubles with running an array through a foreach loop. Let's start with the background:
I am creating an array with the following code:
push(@userData, $user->getID(), ";",$user->getExternalID(), ";", $user +->getExternalParentID(), ";", $user->getSid(), ";", $user->getDomain( +), ";", $user->getLockedTimes() );
where $user->getSomething() is defined elsewhere. The above push statement may be called more than one time. But for now, let's just assume that it is only called once. When I print out the above array, I get the following (which is what I am expecting):

206;homefoldertest1238;TODO;F030624;NAEAST;19

The next thing that I do is run the above array through a foreach loop to process the data in it. To do that I have the following code:
foreach (@currentData) { my ($recordNum, $externalID, $externalParent, $ssid1, $domain1 +, $timesLocked) = split(/;/, $_); print @currentData; print "\nin the foreach loop for $recordNum\n"; }
I was expecting the loop to run once, printing the following:
206;homefoldertest1238;TODO;F030624;NAEAST;19
in the foreach loop for 206


To my surprise, I recieved the following:
206;homefoldertest1238;TODO;F030624;NAEAST;19
in the foreach loop for 206
;homefoldertest1238;TODO;F030624;NAEAST;19
in the foreach loop for
homefoldertest1238;TODO;F030624;NAEAST;19
in the foreach loop for homefoldertest1238
;TODO;F030624;NAEAST;19
in the foreach loop for
TODO;F030624;NAEAST;19
in the foreach loop for TODO
;F030624;NAEAST;19
in the foreach loop for
F030624;NAEAST;19
in the foreach loop for F030624
;NAEAST;19
in the foreach loop for
NAEAST;19
in the foreach loop for NAEAST
;19
in the foreach loop for
19
in the foreach loop for 19


What am I doing wrong here?! Any help would be greatly appreciated.

Frank

In reply to arrays and foreach by fritz1968

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.