Today I did something that's totally insane:
$image = \$image unless ref $image;
The intent was normalising the input to a sub, which can be either the image or a reference to the image's data. My goal was to always have a reference.
After some debugging, it became clear that the "hold a reference to yourself" is plain wrong. I was relying on some obscure reasoning inside my brain, about the fact that taking that reference would magically "detach" the variable container from $image, just to take a reference to the container and put it into a new container in $image.
Luckily, sometimes Perl just refuses to DWIM, and with good reasons.