my $formStatus = $query->param('submitButton'); my $sql13 = "SELECT name, sub_name, good_high, critical_low, warning_low, warning_high FROM comm_desk_thresholds WHERE user = ? "; my $sth13 = $dbh->prepare($sql13); $sth13->execute($userName); my @compare_1; while (my @row_13 = $sth13->fetchrow_array) {#Storing list of values when page is loaded before submit button is clicked push @compare_1, @row_13; } if ( $formStatus eq "Submit" ) { # This code will run only when Submit button is clicked my $sql14 = "SELECT name, sub_name, good_high, critical_low, warning_low, warning_high FROM comm_desk_thresholds WHERE user = ? "; my $sth14 = $dbh->prepare($sql14); $sth14->execute($userName); print $fh "After $sql14 executed (Performance_2): ". localtime()."\n"; my @compare_2; while (my @row_14 = $sth14->fetchrow_array) {#Storing list of values after submit button is clicked push @compare_2, @row_14; } my @diff; for ( my $i=0; $i <($#compare_1+1); $i++) { if ( $compare_1[$i] ne $compare_2[$i] ) { push @diff, $compare_2[$i]; } } #Run business logic for only those elements in @diff. }