It's been mentioned already but I thought I'd give an example in Petal
my $t = Petal->new($template_file);
print $t->process(
user -> $user,
);
Here $user is an object that has many methods that return strings or arrays or other objects. In a Petal expression "user/name" will result in a call to $user->name. "user/account/balance" will result in a call to $user->account->balance. Since these are methods, they can be as lazy as they like, they can pull things out of databases at the last moment, perform complex calculations etc.
In Petal the syntax for hash access is the same as method call (basically it calls a method if it can otherwise it treats it as a hash key) so it's easy to switch between them. Particularly handy when you're protyping and you want to pump some sample data into your template to make sure everything's OK.