I have some 6 field say field 1,field 2,field 3,field 4,field 5,field 6.
You'll have to clarify what you mean by "field"?
Are these substrings within a single string? Or entryfields within an HTML form? Columns in a CSV file?
And also what you mean by "blank"?
Let's say that you have captured the fields into an array, then you might build you binary value this way:
my @fields = ... ;
my $binary = chr(0);
defined( $fields[ $_ ] ) && length( $fields[ $_ ] ) and vec( $binary,
+$_, 1 ) = 1 for 0 .. $#fields;
For example: @fields = ( 'fred', undef, '', 0, 123, ' ' );;
$binary = '';;
vec( $binary, $_, 1 ) = ($fields[ $_ ] // '' ) =~ /\S/ ? 1 : 0 for 0 .
+. $#fields;;
print unpack 'b*', $binary;;
10011000
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|