in reply to Setting Conditional Variable Based on Partial Match

Also, eq (perlop) is used for comparison, not for assignment. I think you want:
$type = "S";

Side note... this:

$PP=$PP+1;

can also be written more concisely as:

$PP++;