in reply to Use of uninitialized value in substitution (s///)

I don't know if this is causing the error, but in your second to last line, that equals should be =~.