title: How to compare values from Array references in perl?
body: <pre><code>#!/usr/bin/perl -C0
  use strict;
  use warnings;   
  use DBI;
  
  sub agg_verification
  {
  my ($list,$tblname,$values);
  my $res1=undef;
  my $res2=undef;
  
      #First DB Connection******
      my $connstr = "ENG=xxx;CommLinks=tcpip{port=xxx};UID=xxx;PWD=xxx";
      my $dbh = DBI-&gt;connect( "DBI:SQLAnywhere:$connstr", '', '', {AutoCommit =&gt; 0} ) or warn $DBI::errstr;
      my $stmt="select col1||':'||col3 as a, col2||'('||col3||')' as b from table where col1 like '%xxxx:((15))%'"; #making 'a' as primary key for fetchall_hashref() later.
      my $sth=$dbh-&gt;prepare($stmt) or warn $DBI::errstr;
      $sth-&gt;execute() or warn $DBI::errstr;
  
      #Second DB Connection******
      my $connstr1 = "ENG=xxx;CommLinks=tcpip{port=xxx};UID=xxx;PWD=xxx";
      my $dbh1 = DBI-&gt;connect( "DBI:SQLAnywhere:$connstr1", '', '', {AutoCommit =&gt; 0} ) or warn $DBI::errstr;
      my ($sth1,$stmt1,$stmt2);
      #creating, opening and writing the result in a file 
         open my $fh, '+&gt;&gt;', "/eniq/home/dcuser/output.txt" or warn "Cannot open output.txt: $!";
  
         my $res = $sth-&gt;fetchall_hashref('a');
  
         foreach my $key(sort keys %$res) {
              my @col1 = $res-&gt;{$key}-&gt;{'a'};
              $list=\@col1;
                  foreach my $item(@$list)
                      {
                          my @values=${$res}{$item}-&gt;{'b'};
                          $values=\@values;
                          my @tblname=$item=~ m/[(\w*)(\:)](DC\w*)/; #trimming table name
                          $tblname =\@tblname;
                          #print $fh "TABLENAME :@$tblname\n";
  
                              foreach my $raw(@$tblname) #Extracting _RAW data*********************
                              {
                                  $raw.="_RAW";
                                  chomp($raw);
                                  $stmt1 = "select @$values from $raw";
                                  $stmt2 = "";
                                  $sth1=$dbh1-&gt;prepare($stmt1) or warn $DBI::errstr;
                                  $sth1-&gt;execute() or warn $DBI::errstr;
                                  my $max_rows1 = 5_000;
                                  $res1 = $sth1-&gt;fetchall_arrayref(undef,$max_rows1);
  
                                                  }
                              foreach my $day(@$tblname) #Extracting _DAY DATA******************** 
                              {
                                  $day  =~ s/(\_RAW)//;
                                  chomp($day);
                                  $day .="_DAY";
                                  $stmt2 = "select @$values from $day";
                                  $sth1=$dbh1-&gt;prepare($stmt2) or warn $DBI::errstr;
                                  $sth1-&gt;execute() or warn $DBI::errstr;
                                  my $max_rows = 5_000;
                                  $res2 = $sth1-&gt;fetchall_arrayref(undef,$max_rows);                              
                                                  }
  
                                  if(@$res1 == @$res2)
                                  {
                                      print $fh "PASS at @$values\n";
                                                  }
                                  else
                                  {
                                      print $fh "FAIL at @$values\n";
                                                  }
                                                      }
                                                          }
  
  
      close $fh or warn "Couldn't close file properly";
          $sth1-&gt;finish();
          $sth-&gt;finish();
          $dbh1-&gt;disconnect;
          $dbh-&gt;disconnect;
  }
  agg_verification();
  </code></pre>
  
  <p>Guys, i want to compare the numerical values coming in $res1 and $res2 but i am not getting the result on which it is passing or failing. My output is all "pass" irrespective of the changes. Please suggest how can i compare values from array references in my code above without using external CPAN library as i don't have permissions to update or add libraries. </p>