while ( <> ) { my @F = split /\|/; foreach ( @F ) { $_ .= '"' if tr/"// & 1; } print join '|', @F; }