Although this probably doesn't contribute to the origin story of either case...
In Perl, a leading underscore is a social contract for a poor man's private member. There are no private members in classic Perl OOP, so using an underscore is a means to communicate that this field or method should not be touched, modified, or invoked directly.
In practice, I usually use a trailing underscore to recreate a variable, like when I'm refactoring. The original variable will be occupied by an old, crappy interface and the new variable, using the exact same name, will be using the shiny, beautiful interface.
var dog = 'golden retriever';
var dog_ = BRD_GOLDEN_RETRIEVER;
process(dog);
Shelter->Process(dog_);
Obviously the side-by-sided-ness is only temporary. dog_'s existence is transient.