Hi,
I have a question about converting some of the data in my dataset but leave some data the way it is.
I have a hash and if the key is present and the Value of the Hash equals B it should convert these number but if B is not present the data should remain the same.
my output is that all the data is converted not in the only the cases were B is present.
This is the script i have
I hope someone can help me with this.
I have a question about converting some of the data in my dataset but leave some data the way it is.
I have a hash and if the key is present and the Value of the Hash equals B it should convert these number but if B is not present the data should remain the same.
my output is that all the data is converted not in the only the cases were B is present.
This is the script i have
Code:
while ($data = <Dataset>) {
if (exists $hash[1]) {
if ($hash[2]==B) {
for ($i = 0; $i < length($data); $i++) {
$characterString = substr($data, $i, 1);
$newCode = $characterString;
if ($characterString eq "1") {
$newCode = "0";
}
if ($characterString eq "0") {
$newCode = "1";
}
if ($characterString eq "2") {
$newCode = "3";
}
if ($characterString eq "3") {
$newCode = "2";
}
substr($data, $i, 1) = $newCode;
}
print "$data\n";
}
else {
print $data\n";
}
Comment