A bug in Perl's autodie

I made a typo in “How does open 0; print <0>; turn every Perl program into a quine?” which was noticed by Peter Roberts. Instead of typing:

open 0;

I wrote:

open $0;

Fixing that results in:

$ cat 0.pl
#!/usr/bin/env perl

use autodie;
use strict;
use warnings;

$0 = 'does not exist';

open 0;
print <0>;

$ ./0.pl
Can't open('0'): No such file or directory at ./0.pl line 10

We can verify that perl tries to open a file called does not exist using strace or dtruss

$ sudo dtruss -f -t open perl 0.pl

which, among other things, shows:

xxxx/yyyyyy:  open("does not exist\0", 0x0, 0x1B6) = -1 Err#2

However, autodie fails to deduce the correct file name for the message.