Could you please explain how this works.

while (m`(?=.)((?:"((?:""|[^"]+)*)")?([^,]*))(,?)`sg) 
print "1=$1  2=$2  3=$3   4=$4 \n";




1=APPLE 2= 3=APPLE 4=,
1=MANGO 2= 3=MANGO 4=,
1="BANNA" 2=BANNA 3= 4=

Logic is not catching to my little brain, pls help. Thanks.

wow, that's quite a regex! I had to go back to perlretut for some more reading - I recommend you do the same and read closely "Embedding comments and modifiers in a regular expression", "Non-capturing groupings" and so on.

I don't want to tell you what you already know - do you know what ?: and ?= etc., do? are you stuck with the whole thing or just a part of it?

Hope this gets you started,