Ok, this has been brewing in my head for some time, but was
precipitated by a message from Gerd Knops over the weekend..
How many of you would like to say:
sub method {
attr shift;
# hash-based object attributes available here as locals
}
The new Alias module provides just this functionality.
The object attributes are simply localized and are available with
the same names as their hash keys. Values that are references are
available as their dereferenced types.
You could use it to also get concise access to hash values:
$hash = {A => 1, B => [2, 3], C => {4 =>5}};
{
attr $hash;
print $A, @B, %C;
}
print $A, @B, %C;
You can get it from CPAN, or from:
http://www-personal.umich.edu/~gsar/Alias-2.0beta.tar.gz
Let me know if you like it.
- Sarathy.
gsar@engin.umich.edu
precipitated by a message from Gerd Knops over the weekend..
How many of you would like to say:
sub method {
attr shift;
# hash-based object attributes available here as locals
}
The new Alias module provides just this functionality.
The object attributes are simply localized and are available with
the same names as their hash keys. Values that are references are
available as their dereferenced types.
You could use it to also get concise access to hash values:
$hash = {A => 1, B => [2, 3], C => {4 =>5}};
{
attr $hash;
print $A, @B, %C;
}
print $A, @B, %C;
You can get it from CPAN, or from:
http://www-personal.umich.edu/~gsar/Alias-2.0beta.tar.gz
Let me know if you like it.
- Sarathy.
gsar@engin.umich.edu