```{index} single: set (Template::Stash::XS) ``` ```{index} single: Template::Stash::XS::set ``` # set Assign `$value` to a template variable named as for `get`, creating the hashes on the way; with a true fourth argument, only when the variable is not already true. Returns the value assigned, or an empty string when nothing was. ## Synopsis ```perl $stash->set('title', 'Home'); $stash->set('user.mail', 'ann@example.org'); # creates user if needed $stash->set('title', 'Default', 1); # only if not already true ``` ## Edge cases - A reference other than a list ref as `$ident` dies "Template::Stash::XS: set (arg 2) must be a scalar or listref". - Names starting with `_` or `.` are private and are not assigned while `$Template::Stash::PRIVATE` is true. - The last element on an object calls its method with `$value` as the last argument.