in reply to hash with a hash

You probably want

$tests{2} = \%blah2;

(i.e., you need to assign a hashref when you're in scalar context...  Otherwise, you get the number of used/allocated buckets of the hash — which is why you see the error 'Can't use string ("2/8") as a HASH ref while "strict refs" in use...')

Replies are listed 'Best First'.
Re^2: hash with a hash
by perlfan (Parson) on Jun 04, 2007 at 19:34 UTC
    Yeah,
    $tests{2} = \%blah2;
    is the same as
    $tests{2} = { condition => "AND", terms => [ "foo", "bar" ], };
    One thing that you should note is that when explicitly defining hashes and arrays, one can use "()"'s.
    my @array = ( 1, 2, 3 ); my %hash = ( A => 1, B => 2, C => 3, );
    However, anonymous arrays are defined with "[]"'s
    my $array_ref = [ 1, 2, 3 ]; my @array = @{$array_ref}; # becomes an explicit array
    and anonymous hashes are defined with "{}"'s.
    my $hash_ref = { A => 1, B => 2, C => 3, }; my %hash = %{$hash_ref}; # becomes an explicit hash