Converting a list to hierachical subscripts

Typical question

I have a unix directory path, say /home/user/mail

Not knowing how long it will be, that is, how many elements, how can I convert it into a sequence of hashes:

 $ref->{'home'}->{'user'}->{'mail'}

Next