On 12.05.2013 03:02, Linda Walsh (via RT) wrote: > # New Ticket Created by Linda Walsh > # Please include the string: [perl #117969] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117969 > > > > > This is a bug report for perl from perl-diddler@tlinx.org, > generated with the help of perlbug 1.39 running under perl 5.16.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > There are sorta 2 problems here with the POSIX module -- they are > related, so figure 1 bug report is sufficient. > I spent an a few hours tracking down why. This > minimal test case shows only 1 warning, but I think it might get the > principle across (if you want the longer program I'll be happy to supply > it). > ---- > #!/usr/bin/perl -w > use Cwd qw(getcwd cwd abs_path realpath); > { > no warnings; use POSIX; #>& /dev/null! > } > --- > Gives: > Subroutine main::getcwd redefined at /tmp/postest.pl line 4. > > That's the first problem -- that there are any warnings. No, that's normal. You're loading two modules, each of which redefines main::getcwd(). > > Second -- is it's not easy to shut them off. It's trivial to shut them off: Just remove -w. There is no reason to use -w in any perl that supports 'use warnings' (i.e. 5.6 or better). > For one reason or another, the > 'no warnings' in front of the > 'use POSIX' doesn't turn them off. The reason is that 'use warnings'/'no warnings' is lexical, i.e. it only affects code in the current block. The actual subroutine redefinition, however, happens in the POSIX module (or probably in Exporter, even). There's no way to influence warnings from other modules via 'use warnings'/'no warnings'. But there is a way to turn on warnings globally, even for modules that don't expect them to be active: the -w switch. > ...(played around some as writing this...) > > It seems "-w" on line 1 is overriding "no warnings in *THIS* program. > I say 'THIS', because I have multiple other programs with the same > construct that work as one would expect: (warnings about something are > silenced in the lexical scope). > > I'm not sure why it would be different here but that's > the 2nd bug 'no warnings' isn't working here. In conclusion: You're describing your mistaken interpretation of what's going on, not what's going on. In fact, it could be argued that the warning is correct as getcwd actually gets redefined. I guess that would be a feature request for Exporter ... ? -- Lukas Mai <plokinom@gmail.com>Thread Previous | Thread Next