sub foo { my $n = $_[0] ? $_[0] : keys %hash; return wantarray() ? (keys %hash)[0..($n-1)] : $n }