Any help would be appreciated.# Open the inventory file open(HANDLE,"<INVENT.TXT"); while(<HANDLE>) { # Separate each field for a single row @info = split(/,/,"$_"); $code = $info[0]; $description = $info[2]; $manuCode = $info[3]; $retailPrice = $info[9]; $invCount = $info[30]; # Strips out useless characters $code = substr($code,1,length($code)-2); $description = substr($description,1,length($description)-2); $manuCode = substr($manuCode,1,length($manuCode)-2); $retailPrice = substr($retailPrice,1,length($retailPrice)-3); $invCount = substr($invCount,1,length($invCount)-5); # Strips out whitespaces when needed and multiple zeros $code =~ s/\ {1,}//g; $description =~ s/\ {2,}//g; $retailPrice =~ s/0{2,}//g; $invCount =~ s/0{2,}//g; # Converts inventory count to 0 if there is no inventory if($invCount == '') { $invCount = 0; } # Compare the manufacturer code and change it if needed while(($key,$value) = each(%catReplace)) { if($manuCode =~ /$key/) { $manuCode = $value; last; } } # Open the manufacturer file open(MAN,"<file.csv"); while(<MAN>) { # Separate each field for a single row @manInfo = split(/,/,"$_"); $manufacturer = $manInfo[0]; $manuID = $manInfo[1]; # THIS IS WHERE I HAVE PROBLEMS if($manuCode =~ /$manuID/) { $manuCode = $manufacturer; last; } } close(MAN); # Open and write the new inventory list open(NEWFILE,">>test.txt"); print NEWFILE $code.',',$description.',',$manuCode.',',$retailPric +e.',',$invCount."\n"; close(NEWFILE); } close(HANDLE);
In reply to Regex problem by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |