Records vs. LH and RH pitchers

As most of you are aware, there is a column heading when displaying the league standings which indicates vs. LH and vs. RH.
Does anyone know how the determination is made for each game? Is it based on the starting pitcher at the beginning of the game, or is it the pitcher of record?
For example, Steve Carlton starts, pitches eight innings, but doesn't get the decision, but reliever Ken Tatum pitches a scoreless ninth, and his team comes back to win, thus KT is the pitcher of record. Now, when the loss is recorded for the opposing team, is it registered as a loss against a LHP (Carlton) or a RHP (Tatum)?
:?
Does anyone know how the determination is made for each game? Is it based on the starting pitcher at the beginning of the game, or is it the pitcher of record?
For example, Steve Carlton starts, pitches eight innings, but doesn't get the decision, but reliever Ken Tatum pitches a scoreless ninth, and his team comes back to win, thus KT is the pitcher of record. Now, when the loss is recorded for the opposing team, is it registered as a loss against a LHP (Carlton) or a RHP (Tatum)?
:?