Article View: pl.comp.lang.perl
Article #52575tie hash i wantarray dla FETCH
From: Piecia aka dracorp
Date: Wed, 25 Feb 2015 07:32
Date: Wed, 25 Feb 2015 07:32
32 lines
1841 bytes
1841 bytes
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
Technical Details
Message-ID:
<56734845-6929-40af-ac84-334b21cb2c48@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!news.supermedia.pl!news.nask.pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.glorb.com!hl2no22711334igb.0!news-out.google.com!c1ni195qar.1!nntp.google.com!j7no6358836qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 10.68.192.10 with SMTP id hc10mr1924739pbc.4.1424849567090; Tue, 24 Feb 2015 23:32:47 -0800 (PST) X-Received: by 10.140.101.148 with SMTP id u20mr22824qge.5.1424849566828; Tue, 24 Feb 2015 23:32:46 -0800 (PST) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!news.supermedia.pl!news.nask.pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.glorb.com!hl2no22711334igb.0!news-out.google.com!c1ni195qar.1!nntp.google.com!j7no6358836qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.perl Date: Tue, 24 Feb 2015 23:32:46 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=195.60.216.126; posting-account=ohlE0woAAADrpn6HW1551lk3wKkUxvh3 NNTP-Posting-Host: 195.60.216.126 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <56734845-6929-40af-ac84-334b21cb2c48@googlegroups.com> Subject: tie hash i wantarray dla FETCH From: Piecia aka dracorp <piotr.rogoza@wp.eu> Injection-Date: Wed, 25 Feb 2015 07:32:46 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit