Why is the s/,,,/,/g; not substituting the single comma?
I think one possibility is that the three commas are spread over two adjoining elements of @L1. If the 3 commas don't belong to the same $line, the regex won't remove them. Try print "@L1"; so you can see whether the 3 commas belong to the same $line.