Re^19: can't import using exporter
by Corion (Patriarch) on Mar 20, 2012 at 07:43 UTC
|
Usually a simple alias BEGIN{ *var=\$DEBUG::var}; is what I remember working -- USED it TONS of times.
Now it doesn't work. Ergo. bug in 5.14. You can claim it is a bug in my code somewhere. It may be... But perl ISN'T flagging the error.
Remember the last time when you had "irrefutable" proof of Perl 5.14 being buggy? It was a one four line program, and the bug was that you didn't read the error message. Why should it be different this time?
| [reply] |
|
|
You seem to be confused. There was no last time. This is all the same question. The error message you claim I should have seen was seen, or rather, NOT seen by you too -- spurring you to go on and write a rather long (required to work around the bugs in 5.14), example of how it worked. -- Except that you don't use any of perl's basic error parsing and library statements. Those are also part of perl. That's were the error is finally working out to be. Never starting in my code.
Errors were created in me using a module I was unfamiliar with and used for the first time. But that was in trying to work around the original bug -- on top of that the workaround didn't work either. It suffers from he same bug. Perl doesn't see the vars being defined in the importing module space.
Thank you very much for helping me clarify where the error was. I was fairly certain I had correct code. I did. It really is verifiably broken.
My ways may be unconventional. It's too bad several people here think that is bad and wrong for me not to follow the crowd.
I will have to thank chromatic, though, for getting me to think about it again after I'd stepped away from it for a bit and getting me curious enough to write a real reduction of my prog -- that fully duplicates the error.
You have an odd view... I make a mistake, I correct it and move on, yet you brought up the same spelling thing that YOU overlooked, in an earlier post, that I did. Perhaps you are more irritated with yourself for missing it?
I known I make mistakes -- but correct and move on, or the problems don't get solved. That's the only way I've gotten as far as I have, is by making alot of mistakes, and correcting them and moving on. But hey, I know other people, they say their stuff doesn't smell... Great. I'm not one of them. (would have been nice!)....
| [reply] |
|
|
By "the last time" I meant to refer you to this post of yours, where you claimed to have found "extraordinary" (your word) proof for 5.14 being buggy. At least I read that post to that intent. In the replies to it, it was shown that you simply failed to understand the error message Perl gave you. I expect more diligence from somebody who claims bugs in Perl.
If you continue to claim that your code is correct, please post that self-contained short program (less than 10 lines) that reproduces the bug, and also the Perl version number on which it works and the Perl version number on which it fails. None of the code you already posted does work differently on any version of Perl 5.
Personally, I recommend that you review Re^23: can't import using exporter and the documentation for the "use" keyword so you understand what steps a use statement consists of, and in what order they happen in your code. Once you've understood that, it should become obvious why your code cannot work and its behaviour is a bug in your code and not in Perl.
| [reply] [d/l] |
|
|
| [reply] |
Re^19: can't import using exporter
by Anonymous Monk on Mar 20, 2012 at 04:25 UTC
|
| [reply] |
Re^19: can't import using exporter
by chromatic (Archbishop) on Mar 20, 2012 at 18:04 UTC
|
Usually a simple alias BEGIN{ *var=\$DEBUG::var}; is what I remember working -- USED it TONS of times.
{
package DEBUG;
our $var = 'foo';
}
{
package main;
BEGIN { *var = \$DEBUG::var };
print "Var is $var\n";
}
$ perl debug_begin.pl
Variable "$var" is not imported at debug_begin.pl line 14.
Global symbol "$var" requires explicit package name at debug_begin.pl
+line 14.
Execution of debug_begin.pl aborted due to compilation errors.
$ perl -v
This is perl, v5.8.9 built for x86_64-linux
(Hint: our scope in this example and still the mess of compilation time versus run time in your longer example.) | [reply] [d/l] |
|
|
#!/usr/bin/perl -w
use strict;
{
package DEBUG;
our $var = 'foo';
}
{
package main;
BEGIN { package Other; *main::var = \$DEBUG::var };
# ^^^^^^^^^^^^^ ^^^^^^
print "Var is $var\n";
}
__END__
Var is foo
It doesn't actually have to be a third package, just not the destination package. So you could also use, for example:
BEGIN { package DEBUG; no strict 'vars'; *main::var = \$var };
| [reply] [d/l] [select] |
|
|
I'm not sure I get your point.
I'm not sure if you are trying to point at a solution or what?
Does Exporter not work for variable names in 6.14? It's documented as supporting them in its pod/manpages, but putting the var in @EXPORT as '$var' and then importing it in another package, doesn't work either in 6.14.
Does it work in your 5.8?
package Debug;
{use parent "Exporter";
our $var="foo";
our @EXPORT=qw($foo);
}
package main;
{import Debug;
print $var;
}'
Name "main::var" used only once: possible typo at -e line 10.
Use of uninitialized value $var in print at -e line 10.
| [reply] [d/l] |
|
|
| [reply] |
|
|
|
|
|
|
|
|