in reply to Bitwise & not working correctly in CGI script

I cannot not recover your issue. If I run the code provided (after adding use Carp 'cluck';, my $job_type = 65;, and a closing quote on your line 4, I get the output on STDERR:
business_unit: at fluff.pl line 7 business_unit: D at fluff.pl line 7 business_unit: D at fluff.pl line 7
I suspect your issue is that what you actually mean to have is something like
use strict; use Carp 'cluck'; my $job_type = 65; my %bj = (64,'D', 128,'A', 256,'H'); foreach my $flag (keys %bj) { if ($flag & $job_type) { my $bu = $bj{$flag}; cluck("business_unit: $bu"); } }

The difference here is that I am now only outputting when the if condition is true; your if applied only to the assignment, not the cluck.

Update: Jenda also has a plausible explanation, if Re: Bitwise & not working correctly in CGI script is correct. This makes sense if you are pulling the string out of $cgi->param, which contains only strings. You can numify the result using my $job_type = 0+ $cgi->param('job');, for whatever those variables are called locally.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.