I have encountered a bug where when the user puts in a value with a letter in it of the second half of ##:##, it starts at 00. For example, Say I go and I pass it 3F:13, the next iteration would be 3F:14, 3F:15, 3F:16... However say I pass it A7:F0, we would expect it to go A7:F1, A7:F2, A7:F3... however it instead goes A7:00, A7:01, A7:02... I have already did several google searches, and looked into perldocs, however I am having trouble finding anything to be able to help me. The closest I have found is that perl assumes that whenever a user puts in a character such as F or B, that it makes it a string. I have already tried, having it be taken more clearly as a decimal I believe, by having the user put in two separate values, but nothing changed. Could anyone please point me in the right direction on where I may be going wrong, or explain to me where I have messed up?#takes the first two characters and stores them for later $AddressOriginal = substr($Address, 0, 3); #removes the first three characters leaving the later ## in the format + ##:## $Address = substr($Address, 3, 2); #Test lines to make sure the above lines do their intended purpose #print $Address . "\n"; #print $AddressOriginal . "\n"; for($count = 1; $count <= $IDcount; $count++) { $hexval = sprintf("%02X\n", ($Address)); $Address++; $Address1 = ($AddressOriginal . $hexval); #Test line to make sure the procedure completed its intended task print $Address1;
In reply to Invalid Hex Conversion? by tfredett
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |