You start with
$w == 0. You post-increment it, which means before changing its value, you perform the
|| die test. Therefore,
0 || die goes the "or" way and dies. Since there was no system failure immediately before the death, the value of $! is meaningless, as documented in
Perl Predefined Variables / $OS_ERROR.