http://qs321.pair.com?node_id=183919

Koschei has asked for the wisdom of the Perl Monks concerning the following question:

Ok, Perl 5.8.0 introduces runtime application of variable attributes. All fine and dandy. However, I'd like to be able to pass variables in my attribute declarations. For example:

my $bar = 3; my Cat $foo : Legs($bar);

As perldelta (perl58delta for bleaders) says:

In particular, however, this allows variable attributes to be useful for "tie" interfaces, which was a deficiency of earlier releases.

So, how does one actually evaluate the $bar? MODIFY_SCALAR_ATTRIBUTES gets called with a string "Legs($bar)" and no hook into the appropriate namespace.

-- Iain, aka Koschei.
  • Comment on runtime variables and runtime attributes.

Replies are listed 'Best First'.
Re: runtime variables and runtime attributes.
by IlyaM (Parson) on Jul 22, 2002 at 08:13 UTC
    Not sure if it will work but you can try to get access to variables using Devel::LexAlias.

    OTOH after playing with attributes I decided for myself to do not use them because they have too many limitations (my favorite is that Perl insists that the entire attribute be on one line).

    --
    Ilya Martynov (http://martynov.org/)