Eugen Konkov
Eugen Konkov

Reputation: 25223

Which alias module better to use?

I want to alias values from source array to hash values

@$data{ $sth->{NAME_lc}->@* } =  $self->source->@*;

What is the best way to accomplish this task?

UPD
Here I want hash value refer to array value. And if hash value is changed the corresponding value in array must be changed too

Upvotes: 2

Views: 67

Answers (1)

Eugen Konkov
Eugen Konkov

Reputation: 25223

I have found this solution:

use Data::Alias;
alias @$data{ $sth->{NAME_lc}->@* } =  $self->source->@*;

UPD
Thanks @amon for refaliasinglists:

\(@$data{ $sth->{NAME_lc}->@* }) =  \($self->source->@*)

UPD
Seems last examples does not work. Aliases are lexically scoped. reported as RT#133538

Data::Alias still works fine

UPD
Data::Alias is most ++ aliasing module on metacpan.org so I think it is the best method as of today. Until refaliasing feature will be fixed.

Upvotes: 1

Related Questions