It’s not a bad idea to carry cash, of course, if the cash is in your wallet, it’s there to spend. (That’s why you carry it, after all.)
If you carry cash only in denominations more than $5, it can help you to not make certain impulse buys: vending machines. Most vending machines will take (a) change, and (b) $1 bills. If you don’t have the right kind of money to feed these machines, it’s almost as if you didn’t have any money at all, because you can’t spend it!
I’ve found that this trick works really well for avoiding the snack machines during those mid-afternoon energy lulls. I’ll just have some water or eat some of the healthier food I have in my cube instead.
Now, if you’re tempted to spend on things after work that are in the $20-$30 range just on impulse, and you know you shouldn’t, then just keep the cash out of your pocket. And the credit cards, for that matter. But if it’s the little expenses that get you, then you can still carry cash without being tempted to spend it on sodas and corn chips at the vending machines. Leave the small money at home!