Hello,
I am trying to create a report that checks for populated values in certain positions of a fixed length record. If there is nothing in the string, then it increments a certain counter and if something exists in the string then it increments another counter. This is the code I have for that:
while (<INPUTFILE>) {
chomp;
my @record = unpack('x2 A1 x1309 A1 A1 A1 A1 A1 A1 A1 x11 A16',$_);
if ( $record[0] eq 'N'){
if ($record[8] eq " "{
$no_cons++;
}
else{
$cons++;
}
}
The string is 16 bytes long and has been pulled by using unpack. I tested this out on a record that does not have anything populated for this string, and still got a increment as if it did. Am I doing this script incorrectly? Or does someone have any advice as to how I can avoid this? The values in the string IF it is populated are always different.
Thanks for any help.
Geek8
I am trying to create a report that checks for populated values in certain positions of a fixed length record. If there is nothing in the string, then it increments a certain counter and if something exists in the string then it increments another counter. This is the code I have for that:
while (<INPUTFILE>) {
chomp;
my @record = unpack('x2 A1 x1309 A1 A1 A1 A1 A1 A1 A1 x11 A16',$_);
if ( $record[0] eq 'N'){
if ($record[8] eq " "{
$no_cons++;
}
else{
$cons++;
}
}
The string is 16 bytes long and has been pulled by using unpack. I tested this out on a record that does not have anything populated for this string, and still got a increment as if it did. Am I doing this script incorrectly? Or does someone have any advice as to how I can avoid this? The values in the string IF it is populated are always different.
Thanks for any help.
Geek8