in reply to Re^4: Queries for elastic search using perl
in thread Queries for elastic search using perl

The fat comma is still a comma. The two structures are identical.

  • Comment on Re^5: Queries for elastic search using perl

Replies are listed 'Best First'.
Re^6: Queries for elastic search using perl
by ravi45722 (Pilgrim) on Jun 29, 2016 at 09:40 UTC

    If it is same I am pushing the hash into the @condition_array in line 65 and checking the size of array in the line 67. Its saying the size of array is 2. But as per you said the size should be one right ???

      No, the size should be 2 because your hash has 2 elements: a key and a value. The hash is expanded into a list when pushed onto an array so the array has 2 new values, the first being the key and the second being the value. eg:

      #!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; my %z = ( a => 'b' ); my @x = ( 'a', 'b' ); my @y = (); push @y, %z; is_deeply (\@x, \@y);

      If you don't want the hash expanded in this way then you must use a reference to it instead when you push it. The reference is then just one element in the resulting array. It will probably help you greatly to have a thorough read of perldsc.

        Very beautiful concept. You Solved my problem. Tq