in reply to problem with foreach

strict/warnings will clobber my $b because $a and $b are special variables. Change the name.

Dead wrong, that first guess. Two modifiers, one statement. Rewrite as,

$_ eq "b" and $b++ foreach @a ;
or,
for (@a) { $b++ if $_ eq "b"; }

After Compline,
Zaxo