January 2015 Archives

Mojolicious and special variable names

I recently started using Mojolicious and this week I encountered a problem when stashing data for rendering in the template.

I tried to stash a reference like this:

my $data = from_json($json_string);
$self->stash(data => $data);

Now when reloading the page it will just render something like HASH(0x85af7b0).

What has happened here is that the "data" variable is used by Mojolicious internally and that is what is rendered instead of the template.

If someone can write a better explanation or point to where this is documented please do so.

About eskaaren

user-pic I blog about Perl.