Here's a solution written in perl, then some explanation on how it works.
In reply to Re: Lights out puzzle (perl solution) by ambrus in thread Lights out puzzle by ambrus