note
rob_au
The documentation for [pos] explains this behaviour - Where a variable is not specified as the first argument to the [pos] function, the match offset is attempted against <code>$_</code>.<p>
In the example code that you provide, you are matching against the variable <code>$str</code> while trying to find the match offset against the default variable <code>$_</code>, which naturally returns an undefined error. If you update the code to either match against the variable <code>$_</code> or return the match offset against the variable <code>$str</code>, your code will execute as expected.
<p> <p>
<tt><font size="-1">perl -le 'print+unpack("N",pack("B32","00000000000000000000000111111010"))'</font></tt>
220153
220158