in reply to Nested Loop Problems

I tried to write some code to help you out, but I'm not at all sure what you're doing. First, split works on strings, not arrays. It also returns a list. So...

split(/,/,@array1,4);
attempts to split an array, which is never going to happen. Then...
$list=split(/,/,@array1,4);
attempts to assign the list that you wanted to appear to $list, which is a scalar. In scalar context, split returns the number of elements that resulted from the split, not the elements themselves. And foreach also works on lists, not scalars.

Regarding your data, is it lines of data with embedded newlines? As newlines, wouldn't they be separate lines already? Anyway, maybe this will help:

foreach my $line (<DATA>) { #assuming you have a data source chomp $line; @lines = split /\\n/, $line, 4; foreach $l (@lines) { # <--that's an L, not a one $l =~ s/^,//; @elems = split /,/, $l; print "$_ " for @elems; print "\n"; } } __DATA__ name1,a1,b1,c1,\n,name2,a2,b2,c2\nname3,a3,b3,c3,\n,name4,a4,b4,c4 name5,a5,b5,c5,\n,name6,a6,b6,c6\nname7,a7,b7,c7,\n,name8,a8,b8,c8
This produces:
name1 a1 b1 c1 name2 a2 b2 c2 name3 a3 b3 c3 name4 a4 b4 c4 name5 a5 b5 c5 name6 a6 b6 c6 name7 a7 b7 c7 name8 a8 b8 c8
--marmot

Further reading: