Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^7: Queries for elastic search using perl

by hippo (Bishop)
on Jun 29, 2016 at 09:50 UTC ( [id://1166866]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^8: Queries for elastic search using perl
by ravi45722 (Pilgrim) on Jun 29, 2016 at 12:32 UTC
    Very beautiful concept. You Solved my problem. Tq

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1166866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-16 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found