$h below is an object, but it only contains a regular hash.
my $h = YAML::Syck::LoadFile('have_seen.yaml');
If it was a normal hash then the number of keys would just be keys $h.
Question
How to get the numbers of keys when the hash is in an object?
Update
This is code
#!/usr/bin/perl
use strict;
use YAML::Syck;
my $h = YAML::Syck::LoadFile('h.yaml');
my $links = 100;
print $links - keys $h . "\n";
The yaml file contains
---
010711: 1
---
$his not an object, but a plain hashref. This is really an operator precedence problem. Use parentheses to bind the argument to thekeysfunction tight.As Greg Bacon pointed out, on old Perls it is necessary to manually dereference first with
%$hor%{ $h }(which is the better style).