Data storage persistent only for the next request, stored in the "session".
Also notice how the documentation shows pairing it with "redirect_to" (a next request). Rendering, as you're doing, isn't a next request, the rendering is happening on
this request. So rather than flash, I think you just want to stash.
...
if ($error) { return $c->render('derns', mots => $mots, error_message => "Il n'y a pas ...", aide => 1) }
...
@@ derns.html.ep
...
% if (my $err_msg = stash 'error_message') {
...
Now, if you want an error message to show when you redirect_to("vueprincipale") then you'd want to flash.
$c->flash(error => 'message')->redirect_to('vueprincipale');
...
@@ vueprincipale.html.ep
...
if (my $err_msg = flash 'error') {
...