When appending new members to an existing array of hash in this manner, how can I check whether it's indeed a key -> value pair that I inserted? : I have one of the weirdest of problems, and I spent too much time trying to figure out where I am making an error. I am trying to debug an issue *(not my source entirely)*.

I have a package I made which is a wrapper for `IO::Socket` to create socket.

    package mysock::my_sock;
    use strict;
    use warnings;
    use Scalar::Util 'refaddr';
    use IO::Docket;
    use IO::Select;
    
    my %socket;
    my $flag = 0;
    
    sub new {
       my $class = shift;
       my $args = shift;
       my $sock = new IO::Socket::INET(%{args});
       if (!$sock) { 
          warn "Cannot create socket: $!/$@\n" if ($flag); 
          return undef; 
       }

       # Initialize some vars for class
       $socket{ refaddr $obj }->{_SOCKET_} = $sock;
       $socket{ refaddr $obj }->{_SELECT_} = $sel;
       $socket{ refaddr $obj }->{_EOL_}    = $eol;
       $socket{ refaddr $obj }->{_BUFFER_} = {};

       return $obj;
      }
    
     1;
    }

Now when I call/use my package in my script this way everything **works fine** :

    use warnings;
    use mysock::my_sock;
    sub new {
    	      my $var = mysock::my_sock->new({
                                          ip    => '10.109.157.249',  # Hard coded IP addr
                                          port  => '2002',            # Hard coded port
                                          reuse => 1,
                                          eol   =>''
                                       }) or die "unable to connect $!\n";
               return var;
            }  # This sub will go to another package, putting it here for brevity.
     
    my $box = new();

The above code is straight forward. I have created a socket handle successfully. **No** problems so far.

But when I modify my new function this way in my script so that i could pass the ip and port, i can't get it to work no matter what i do:

    sub new {
        my ($ip_, $port_) = @_;
        my @AoH = (
    				 {
    					reuse => 1,
    					eol =>''
    				  }
    			  );
    	$AoH[0]{ip} = $ip_ ;               #insert key => value to my AoH
    	$AoH[0]{port} = $port_ ;           #insert key => value to my AoH
    	my $var = mysock::my_sock->new($AoH[0]) or die "unable to connect- $!\n";
        return $var;
      }

     my $box = new('10.150.180.245','2011');   # pass ip/port as args.
      

I tried passing `my $var = mysock::my_sock->new($AoH)` or `my $var = mysock::my_sock->new($AoH)` and even `my $var = mysock::my_sock->new(\@AoH)`. None of these works. 

When I dump the `$args` that I get inside my package, for both cases it prints a hash: 

    $VAR1 = {
               "reuse" => 1,
               "ip" => "10.63.122.49",
               "port" => 6002,
               "eol" => ""
             };

I am using perl debugger, and it shows the same hash above when i run my script either way, which is what confuses me. If they are the same, then why won't the second method work?

Could the hash somehow gotten over written? I dunno what's gone wrong. `$sock` in my package doesn't get the socket, and I couldn't get `IO::Socket` to bless me w/ a socket call when i use my modified function where i pass the params so i return `undef`.

Can you help?