Benim hashref'in 0 elementi içerip içermediğini test etmem gerekiyor. Bu kodu kullandı:Bir hash referansının perl içinde boş olup olmadığını nasıl kontrol edeceğim
$self = { fld => 1 };
%h = ("a" => "b");
$self->{href} = { %h };
print STDERR $self->{href}{ "a" };
print STDERR "\n";
print "size of hash: " . keys(%h) . ".\n";
print "size of hashref: " . keys($self->{href}) . ".\n";
Bu perl 5.16 ile iyi çalışır, ancak Perl 5.10 ile başarısız:
Type of arg 1 to keys must be hash (not hash element) at - line 7, near "}) "
Execution of - aborted due to compilation errors.
olsun. Tüm Perl versiyonlarında aynı şekilde mi çalışacak? –
Hayır. Bu, terk edilmiş bir deneysel özellikti. – ikegami
Bu dönüş boş mu yoksa 0? – landesko