Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autodie fails to deduce filename for open FILEHANDLE [rt.cpan.org #99402] #94

Open
toddr opened this issue Jan 16, 2020 · 0 comments
Open
Labels

Comments

@toddr
Copy link
Collaborator

toddr commented Jan 16, 2020

Migrated from rt.cpan.org#99402 (status was 'new')

Requestors:

From [email protected] on 2014-10-09 20:36:53:

AFAIK, when open fails, autodie's intends to show an error message with the name of the file that could not be opened:

Error message from the following script should be "Can't open('does not exist'): ..."

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

use autodie;
use strict;
use warnings;

our $FILE = 'does not exist';
open FILE;
$ ./0.pl
Can't open('FILE'): No such file or directory at ./0.pl line 8

On OSX, dtruss shows:

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

On Linux, strace shows:

open("does not exist.txt", O_RDONLY) = -1 ENOENT (No such file or directory)

To my dismay, I found that perldoc -f open in most recent versions of Perl don't have this, but versions as recent as 5.18.2 explain what happens when open is invoked with a single argument:

If EXPR is omitted, the global (package) scalar variable of the same name as the FILEHANDLE contains the filename.

For other info, see:

http://blog.nu42.com/2014/10/a-bug-in-perls-autodie.html

http://blog.nu42.com/2014/10/why-was-documentation-for-single.html

Clearly, open FILENAME cannot be recommended, so I am putting very low priority on this, but FYI.

Thank you,

-- Sinan

@toddr toddr added the Needs PR label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant