The subject line may not correctly describe the problem but that is probably
because I don't really understand the problem myself.  Here's a brief
rundown of what I am trying to do:
    I have a string that is delimited by pipes ( | )
    Within each subset of the string there are one or more other value pairs
    Each of those pairs is separated from the others by a semi-colon ( ; )
    The name and value in each pair may be split by a colon ( : ) or an
equals sign ( = )

    I want to create one array that contains all the data parsed out into
individual pieces
    Here is the code:

    1)        $t =
"content-type:image/gif;name=clip3.gif|content-transfer-encoding:base64|cont
ent-disposition:attachment;filename=clip3.gif|";    
    2)       @tt = split(/\|/,$t);  # split the string on the pipe character
    3)        $counter = 0;  # initialize the counter
    4)        foreach $e(@tt)  # loop through each element of the array tt
    5)        {
    6)            @tt[$counter] = split(/\;/,$e);  # split the value of $e
and re-assign the value of $tt[$counter] to the resulting array
    7)            foreach $f(0..$#{$tt[$counter]})  # loop through each
element just assigned
    8)            {
    9)                print "$f  is  $tt[$counter][$f]\n";  # print the
index of the current iteration and the value associated with it
   10)            }
   11)            $counter++;  # increment the counter
   12)        }

    What happens is not what I expected.  I expected to get an array that
would look something like this:
       $tt[0][0] = "content-type:image.gif"
       $tt[0][1] = "name=clip3.gif"
       $tt[1][0] = "content-transfer-encoding:base64"
       $tt[2][0] = "content-disposition:attachment"
       $tt[2][1] = "filename=clip3.gif"

    What I seem to end up with a single dimensional array that only contains
the values for the zero indices of the second dimension.
       $tt[0] = "content-type:image.gif"
       $tt[1] = "content-transfer-encoding:base64"
       $tt[2] = "content-disposition:attachment"
       
    Another thing I noticed is that $e gets re-assigned after the execution
line #6.  Is $e treated more like a pointer in the context of line #4?

    If anyone has any comments or advice, I would appreciate it.

Thanks,
Chris

        

Reply via email to