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

perlvar/Errno contradict each other about %! #13177

Closed
p5pRT opened this issue Aug 18, 2013 · 14 comments
Closed

perlvar/Errno contradict each other about %! #13177

p5pRT opened this issue Aug 18, 2013 · 14 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 18, 2013

Migrated from rt.perl.org#119359 (status was 'resolved')

Searchable as RT119359$

@p5pRT
Copy link
Author

p5pRT commented Aug 18, 2013

From @mauke

Created by @mauke

This bug report is about the documentation for %!.

perldoc perlvar says​:

  %! Each element of "%!" has a true value only if $! is set to that value.
  ...

perldoc Errno says​:

  "Errno" also makes "%!" magic such that each element of "%!" has a non-zero
  value only if $! is set to that value.

So which is it? Is %! a normal builtin variable like $! (and therefore always
available), or is it provided by the Errno module (which you'd have to load
first)?

Perl Info

Flags:
    category=library
    severity=low
    module=Errno

This perlbug was built using Perl 5.12.1 - Thu Jun  3 20:09:15 CEST 2010
It is being executed now by  Perl 5.18.1 - Tue Aug 13 07:08:47 CEST 2013.

Site configuration information for perl 5.18.1:

Configured by mauke at Tue Aug 13 07:08:47 CEST 2013.

Summary of my perl5 (revision 5 version 18 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=3.5.7-gentoo, archname=i686-linux
    uname='linux nora 3.5.7-gentoo #5 preempt sat jan 26 16:46:10 cet 2013 i686 amd athlon(tm) 64 processor 3200+ authenticamd gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -flto',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-O2 -flto -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector'

Locally applied patches:
    SAVEARGV0 - disable magic open in <ARGV>


@INC for perl 5.18.1:
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.1/i686-linux
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.1
    /home/mauke/usr/local/lib/perl5/5.18.1/i686-linux
    /home/mauke/usr/local/lib/perl5/5.18.1
    .


Environment for perl 5.18.1:
    HOME=/home/mauke
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH=/home/mauke/usr/local/lib
    LOGDIR (unset)
    PATH=/home/mauke/usr/perlbrew/bin:/home/mauke/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3:/opt/sun-jdk-1.4.2.13/bin:/opt/sun-jdk-1.4.2.13/jre/bin:/opt/sun-jdk-1.4.2.13/jre/javaws:/opt/dmd/bin:/usr/games/bin
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_PATH=/home/mauke/usr/perlbrew/bin
    PERLBREW_ROOT=/home/mauke/usr/perlbrew
    PERLBREW_VERSION=0.27
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 18, 2013

From victor@vsespb.ru

Seems Errno.pm is auto-loaded when accessing %!

$perl -e 'print join q{ }, keys %INC'
(nothing)

$perl -e '$!=1; print join q{ }, keys %INC'
(nothing)

$perl -e '$!=1; $!{AnyValue}; print join q{ }, keys %INC'
strict.pm Exporter.pm Errno.pm

see perl 5005delta​:
http​://search.cpan.org/~rjbs/perl-5.18.0/pod/perl5005delta.pod#%!_is_transparently_tied_to_the_Errno_module

also, I think there was a discussion about it
http​://www.nntp.perl.org/group/perl.perl5.porters/2001/03/msg33102.html

2013/8/19 l.mai@​web.de <perlbug-followup@​perl.org>

# New Ticket Created by l.mai@​web.de
# Please include the string​: [perl #119359]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=119359 >

This is a bug report for perl from l.mai@​web.de,
generated with the help of perlbug 1.39 running under perl 5.18.1.

-----------------------------------------------------------------
[Please describe your issue here]

This bug report is about the documentation for %!.

perldoc perlvar says​:

%\!      Each element of "%\!" has a true value only if $\! is set to

that value.
...

perldoc Errno says​:

"Errno" also makes "%\!" magic such that each element of "%\!" has a

non-zero
value only if $! is set to that value.

So which is it? Is %! a normal builtin variable like $! (and therefore
always
available), or is it provided by the Errno module (which you'd have to load
first)?

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=library
severity=low
module=Errno
---
This perlbug was built using Perl 5.12.1 - Thu Jun 3 20​:09​:15 CEST 2010
It is being executed now by Perl 5.18.1 - Tue Aug 13 07​:08​:47 CEST 2013.

Site configuration information for perl 5.18.1​:

Configured by mauke at Tue Aug 13 07​:08​:47 CEST 2013.

Summary of my perl5 (revision 5 version 18 subversion 1) configuration​:

Platform​:
osname=linux, osvers=3.5.7-gentoo, archname=i686-linux
uname='linux nora 3.5.7-gentoo #5 preempt sat jan 26 16​:46​:10 cet 2013
i686 amd athlon(tm) 64 processor 3200+ authenticamd gnulinux '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -flto',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.8.1', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries​:
ld='cc', ldflags ='-O2 -flto -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.15'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib
-fstack-protector'

Locally applied patches​:
SAVEARGV0 - disable magic open in <ARGV>

---
@​INC for perl 5.18.1​:
/home/mauke/usr/local/lib/perl5/site_perl/5.18.1/i686-linux
/home/mauke/usr/local/lib/perl5/site_perl/5.18.1
/home/mauke/usr/local/lib/perl5/5.18.1/i686-linux
/home/mauke/usr/local/lib/perl5/5.18.1
.

---
Environment for perl 5.18.1​:
HOME=/home/mauke
LANG=en_US.UTF-8
LANGUAGE (unset)
LC_COLLATE=POSIX
LD_LIBRARY_PATH=/home/mauke/usr/local/lib
LOGDIR (unset)

PATH=/home/mauke/usr/perlbrew/bin​:/home/mauke/usr/local/bin​:/usr/local/bin​:/usr/bin​:/bin​:/opt/bin​:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3​:/opt/sun-jdk-1.4.2.13/bin​:/opt/sun-jdk-1.4.2.13/jre/bin​:/opt/sun-jdk-1.4.2.13/jre/javaws​:/opt/dmd/bin​:/usr/games/bin
PERLBREW_BASHRC_VERSION=0.43
PERLBREW_HOME=/home/mauke/.perlbrew
PERLBREW_PATH=/home/mauke/usr/perlbrew/bin
PERLBREW_ROOT=/home/mauke/usr/perlbrew
PERLBREW_VERSION=0.27
PERL_BADLANG (unset)
PERL_UNICODE=SAL
SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 18, 2013

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 18, 2013

From ebhanssen@allverden.no

That could surely be expressed more clearly, but they don't actually
contradict one another. %! is provided by Errno, but you don't need to
C<use> it​: Errno is automatically loaded when %! is seen​:

eirik@​greencat[01​:02​:27]$ perl -E 'say for keys %INC'
feature.pm
eirik@​greencat[01​:02​:57]
$ perl -E 'say for keys %INC; say tied(%!)'
Exporter.pm
strict.pm
Errno.pm
feature.pm
Errno=HASH(0x987ff8)
eirik@​greencat[01​:02​:58]$ perl -E 'say for keys %INC; say tied(%!) if 0'
Exporter.pm
strict.pm
Errno.pm
feature.pm
eirik@​greencat[01​:03​:00]
$

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2013

From @mauke

On Sun Aug 18 16​:00​:53 2013, vsespb wrote​:

Seems Errno.pm is auto-loaded when accessing %!

$perl -e 'print join q{ }, keys %INC'
(nothing)

$perl -e '$!=1; print join q{ }, keys %INC'
(nothing)

$perl -e '$!=1; $!{AnyValue}; print join q{ }, keys %INC'
strict.pm Exporter.pm Errno.pm

see perl 5005delta​:
http​://search.cpan.org/~rjbs/perl-

5.18.0/pod/perl5005delta.pod#%!_is_transparently_tied_to_the_Errno_module

also, I think there was a discussion about it
http​://www.nntp.perl.org/group/perl.perl5.porters/2001/03/msg33102.html

Ah, thanks.

I've attached three patches to ext/Errno/Errno_pm.PL.

- The first one adds the autoloading thing to the Errno documentation.
- The second one changes the "this file was autogenerated" comment to
also mention name of the script it was generated by.
- The third one changes the code example to use lexical variables /
3-arg open instead of barewords / 2-arg open.

What do you think?

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2013

From @mauke

0002-Errno-mention-what-script-it-was-generated-from.patch
From 322b0e994a1566e15e1d4604378e63c2e01e6915 Mon Sep 17 00:00:00 2001
From: Lukas Mai <l.mai@web.de>
Date: Mon, 19 Aug 2013 07:09:36 +0200
Subject: [PATCH 2/3] Errno - mention what script it was generated from

---
 ext/Errno/Errno_pm.PL | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index acc23e8..b67c597 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -283,7 +283,8 @@ sub write_errno_pm {
     print <<"EDQ";
 # -*- buffer-read-only: t -*-
 #
-# This file is auto-generated. ***ANY*** changes here will be lost
+# This file is auto-generated by ext/Errno/Errno_pm.PL.
+# ***ANY*** changes here will be lost.
 #
 
 package Errno;
-- 
1.8.1.5

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2013

From @mauke

0003-Errno-lexical-filehandles-3-arg-open-in-example.patch
From 2ac228fd8f0c134d9978b91228942626050eb8cb Mon Sep 17 00:00:00 2001
From: Lukas Mai <l.mai@web.de>
Date: Mon, 19 Aug 2013 07:10:26 +0200
Subject: [PATCH 3/3] Errno - lexical filehandles/3-arg open in example

---
 ext/Errno/Errno_pm.PL | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index b67c597..df49288 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -412,9 +412,8 @@ tag, C<:POSIX>, which will export all POSIX defined error numbers.
 C<Errno> also makes C<%!> magic such that each element of C<%!> has a
 non-zero value only if C<$!> is set to that value. For example:
 
-    use Errno;
-
-    unless (open(FH, "/fangorn/spouse")) {
+    my $fh;
+    unless (open($fh, "<", "/fangorn/spouse")) {
         if ($!{ENOENT}) {
             warn "Get a wife!\n";
         } else {
-- 
1.8.1.5

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2013

From @mauke

0001-Errno-mention-that-using-autoloads-Errno.patch
From c056eee256b4366be2d4965677c29406e9e5818f Mon Sep 17 00:00:00 2001
From: Lukas Mai <l.mai@web.de>
Date: Mon, 19 Aug 2013 07:07:17 +0200
Subject: [PATCH 1/3] Errno - mention that using %! autoloads Errno

---
 ext/Errno/Errno_pm.PL | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index b372875..acc23e8 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -425,6 +425,9 @@ If a specified constant C<EFOO> does not exist on the system, C<$!{EFOO}>
 returns C<"">.  You may use C<exists $!{EFOO}> to check whether the
 constant is available on the system.
 
+Perl automatically loads C<Errno> the first time you use C<%!>, so you don't
+need an explicit C<use>.
+
 =head1 CAVEATS
 
 Importing a particular constant may not be very portable, because the
-- 
1.8.1.5

@p5pRT
Copy link
Author

p5pRT commented Aug 25, 2013

From victor@vsespb.ru

I think OP submited some patches to RT (
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=119359 ) , but not to p5p
mailing list.

2013/8/19 Eirik Berg Hanssen via RT <perlbug-followup@​perl.org>

That could surely be expressed more clearly, but they don't actually
contradict one another. %! is provided by Errno, but you don't need to
C<use> it​: Errno is automatically loaded when %! is seen​:

eirik@​greencat[01​:02​:27]$ perl -E 'say for keys %INC'
feature.pm
eirik@​greencat[01​:02​:57]
$ perl -E 'say for keys %INC; say tied(%!)'
Exporter.pm
strict.pm
Errno.pm
feature.pm
Errno=HASH(0x987ff8)
eirik@​greencat[01​:02​:58]$ perl -E 'say for keys %INC; say tied(%!) if 0'
Exporter.pm
strict.pm
Errno.pm
feature.pm
eirik@​greencat[01​:03​:00]
$

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=119359

@p5pRT
Copy link
Author

p5pRT commented Aug 25, 2013

From victor@vsespb.ru

I wonder.

Currently programmer doesn't have to list Errno.pm in prerequirements
(prereqs in CPAN meta), and doesn't have to care about vendors who
decouple Perl core modules from core. It just works.

And if we explicitly document relation between Errno and %!, will above
still be true?

On Sun Aug 25 01​:27​:02 2013, vsespb wrote​:

I think OP submited some patches to RT (
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=119359 ) , but not to p5p
mailing list.

2013/8/19 Eirik Berg Hanssen via RT <perlbug-followup@​perl.org>

That could surely be expressed more clearly, but they don't actually
contradict one another. %! is provided by Errno, but you don't need to
C<use> it​: Errno is automatically loaded when %! is seen​:

eirik@​greencat[01​:02​:27]$ perl -E 'say for keys %INC'
feature.pm
eirik@​greencat[01​:02​:57]
$ perl -E 'say for keys %INC; say tied(%!)'
Exporter.pm
strict.pm
Errno.pm
feature.pm
Errno=HASH(0x987ff8)
eirik@​greencat[01​:02​:58]$ perl -E 'say for keys %INC; say tied(%!)
if 0'
Exporter.pm
strict.pm
Errno.pm
feature.pm
eirik@​greencat[01​:03​:00]
$

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=119359

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 2016

From @mauke

On Sun, 18 Aug 2013 22​:18​:29 -0700, mauke- wrote​:

I've attached three patches to ext/Errno/Errno_pm.PL.

- The first one adds the autoloading thing to the Errno documentation.
- The second one changes the "this file was autogenerated" comment to
also mention name of the script it was generated by.
- The third one changes the code example to use lexical variables /
3-arg open instead of barewords / 2-arg open.

Applied as edf1328.

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 2016

@mauke - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant