Hello. There is a code that takes data from the database, and, according to the regular schedule, writes or does not write data in the database. The code is worked out separately correctly, but if before it is executed exactly the same sub, with a similar regular, it gives an error. I can not understand from what it arises, from the database data is issued without problems. data in text form contains data of the form '2400000032632'
sub CheckCorrectEanForSelfMake { my $sqlqueryean = "SELECT EAN FROM `eanfromreport` WHERE DESCRIPTION is NULL OR DESCRIPTION in ('NULL','NothingFind','') AND EAN is not NULL"; my $dbquery1 = $db->prepare($sqlqueryean); $dbquery1->execute; my @rowPRODGRPs;#ΠΠ°Π΄Π°Π΅ΠΌ ΠΈΠΌΡ ΠΌΠ°ΡΡΠΈΠ²Ρ while (my ($rowPRODGRP) = $dbquery1->fetchrow_array()) { push @rowPRODGRPs, $rowPRODGRP; my $EanNameFromDatabase = $rowPRODGRPs[$i]; if ($EanNameFromDatabase =~ /^28/) { my $dbqueryifEanisStartWiht28 = "update EANFROMREPORT set DESCRIPTION = 'Own PRD' WHERE EAN = '$EanNameFromDatabase'"; my $dbqueryEanisStartWiht28 = $db->prepare($dbqueryifEanisStartWiht28); $dbqueryEanisStartWiht28->execute; print "Thith is Own prd\n "; } else { print "Not Own prd\n "; } $i++ } return 1; } Throws an error in the if ($EanNameFromDatabase =~ /^28/) line if ($EanNameFromDatabase =~ /^28/)
Use of uninitialized value $EanNameFromDatabase in substitution (s///)
$EanNameFromDatabasebefore thisif? - Regent=~ /^28/- this is a search in the string by reg. expressions, not a replacement (m//, nots///). - Regentupdate EANFROMREPORT set DESCRIPTION = 'Own PRD' WHERE EAN like '28%' and (DESCRIPTION is NULL OR DESCRIPTION in ('NULL','NothingFind',''))- Mike