in reply to search for '\' in perl

The line if($_ = /\\/) is probably not doing what you want it to do. Either you mean if($_ =~ m/\\/) which would mean "if it contains '\'", or you mean if($_ eq '\') which would mean "if it is '\'".

if($_ = /\\/) is attempting to assign something to $_, and testing if the assignment succeed. Probably not what you want.