Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tie hash i wantarray dla FETCH

9 views
Skip to first unread message

Piecia aka dracorp

unread,
Feb 25, 2015, 2:32:47 AM2/25/15
to
Witam
Mam związany hash z klasą za pomocą tie. Wartości dla tego hasha to tablica dwuelementowa. Pytanie dlaczego dla wantarray* nigdy nie zwraca true dla postaci:
#v+
my @array = $hash{klucz};
#v-
Jedyny sposób żeby pobrać tablicę to:
#v+
tied(\%hash)->FETCH('klucz');
#v-

Na początku myślałem że to wina starego Perla, 5.8.8 ale na nowym jest to samo.

*)
#v+
sub FETCH {
my ( $self, $key ) = @_;

if ( exists $self->{$key} ){
if ( wantarray ){
return @{$self->{$key}};
}
else {
return $self->{$key}->[VALUE];
}
}
return;
}
#v-

--
Pozdrawiam Piotr
piecia aka dracorp
0 new messages