I have a while statement that goes through data and see if there are any matches using an if statement. Problem is when I test it with matching data. I don't get the desired results.
while ( my $unit = $units->next ) {
my $priordata = $unit->priordata;
my $uid = $unit->uid;
my $unitpages = $respondent->pages->search( { form => { -like => 'prior/edit_%/' . $uid } } );
while ( my $page = $unitpages->next ) {
my $pagedata = $page->data;
$priordata->{Q2} = $pagedata->{Q2} if $pagedata->{Q2}; #NAME
$priordata->{Q1_1} = $pagedata->{Q1_1} if $pagedata->{Q1_1}; #STATE
$priordata->{Q1_2} = $pagedata->{Q1_2} if $pagedata->{Q1_2}; #DOCID
$priordata->{Q5_1} = $pagedata->{Q5_1} if $pagedata->{Q5_1}; #MONTH
$priordata->{Q5_2} = $pagedata->{Q5_2} if $pagedata->{Q5_2}; #YEAR
}
$priordata->{Q5_1} = sprintf( '%02s', $priordata->{Q5_1} ) // '00';
$priordata->{Q1_2} =~ s/[-]+//g;
$priordata->{Q1_2} = uc $priordata->{Q1_2};
$docid =~ s/[-]+//g;
$priordata->{Q2} = uc $priordata->{Q2};
$name2 =~ s/[,]+//g;
if ( ( $state == $priordata->{Q1_1} )
and ( uc $docid =~ m/$priordata->{Q1_2}/i ) )
and ( $month == $priordata->{Q5_1} )
and ( $year == $priordata->{Q5_2} )
and ( uc $name2 =~ m/$priordata->{Q2}/i ) )
{
$match = 1;
last;
}
}
I put in data that should match. But I am always getting a 0 for $match. Is there something wrong with the if statement> Thanks for any input.
Aucun commentaire:
Enregistrer un commentaire