Hmmm, I'm not sure what's wrong below... I did a test, and yes indeed, you
can push blank values at an array, and it stores them without a problem... I
made arrays with a hundred empty values with no problem, yet the following
routine sometimes fails to register empty values, thus losing the field
position...

WHAT is it that can be pushed at an array that will NOT add an element? I
don't get it.

--Jon


> sub process
> {
>       # %CvCaseDef;
>       my $rec = shift;
>       my @fields;
>       my $counter = 0;
>
>       my $max = $#{ [ keys %CvCaseDef ] };
>       # print "Max: " . $max . "\n\n";
>
>       foreach my $pos ( @cvcaseheaders ) {
>
>               # print "\t$pos\n";
>
>               my $fname    = $CvCaseDef{$pos}->[1];
>               my $ftype    = $CvCaseDef{$pos}->[2];
>               my $offset   = $CvCaseDef{$pos}->[0];
>               my $fieldval = unpack("a*", substr($rec, $pos - 1,
> $offset));
>               my $packval  = unpack("N", $fieldval);
>
>               if ($pos == 1) {
>                       push @fields, $packval;
>               }
>               elsif ($ftype eq 'BI') {
>                       # Convert a 3-byte binary to 4-byte, then
> decode it...
>                       $fieldval = unpack("N", pack("B8", "0" x
> 32) . $fieldval);
>                       push @fields, $fieldval; # || ' ';
>               }
>               elsif ($ftype eq 'N') {
>                       # Convert a 'Network' number...
>                       push @fields, $packval; # unpack("N",
> $fieldval); # || ' ';
>               }
>               else {
>                       # ANSI field...
>                       # push @fields, unpack("A*", $fieldval);
>                       push @fields, $fieldval; # || ' ';  # Push
> a value or a null. #
>               }
>       }
>
>       my $delim = 0;
>       my $fc = $#fields;
>
>       if ($fc != $max)  { print "FIELD COUNT: " . $#fields . "\n"; }
>
>       foreach my $e (@fields) {
>               # print OUT '"' . $e . '", ';
>               print OUT $e;
>
>               ################################
>               # Check to see whether to print a deliminator,
>               # or a line ending.
>               ################################
>               if ($delim >= $#fields)
>               {
>                       print OUT "\n";
>               } else {
>                       print OUT ', ';
>               }
>               $delim++;
>       }
> }
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
>

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to