```{index} single: modify_attrs; attributes function ``` ```{index} single: attributes::modify_attrs; Perl function ``` # modify_attrs Apply a list of attributes to a referent and return the ones Perl didn't recognise, so the caller can hand them to a user-defined `MODIFY_${type}_ATTRIBUTES` handler. ## Synopsis ```perl my @unknown = attributes::_modify_attrs(\&foo, 'lvalue', 'Bent'); ## 'lvalue' consumed internally; 'Bent' returned for package dispatch. ``` ## What you get back The list of attribute names that weren't built-in. Built-in attributes (`lvalue`, `method`, `const`, `prototype(...)` for subs; `shared` for variables) are applied to the referent directly and do not appear in the returned list. ## Examples ```perl ## Mark a sub as lvalue, no leftovers: sub s :lvalue { $x } my @left = attributes::_modify_attrs(\&s, 'lvalue'); # () ``` ```perl ## Install a prototype via attribute: sub p { } attributes::_modify_attrs(\&p, 'prototype($$)'); # () ``` ```perl ## Custom attribute flows through: my @left = attributes::_modify_attrs(\&s, 'MyTag'); # ('MyTag') ``` ## Edge cases - Called with zero args or a non-reference first arg: croaks with `Usage: attributes::_modify_attrs(@attributes)`. - A `prototype(` attribute without a closing `)` croaks with `Unterminated attribute parameter in attribute list`. - `-shared` on a non-sub referent croaks with `A variable may not be unshared`. ## Differences from upstream - `lvalue` is always consumed as a built-in on `CODE` referents; the "already-defined subroutine" warning dispatch lives in `attributes.pm` and is not mirrored inside this XS entry. ## See also - `_fetch_attrs` — read-side counterpart, returns built-in attrs only. - `get` — public API: `_fetch_attrs` plus `FETCH_${type}_ATTRIBUTES`. - `_guess_stash` — used by `get` to locate the owning package.