Post some code. Read I know what I mean. Why don't you? first.
You should be able to reproduce the problem in 20 lines of code or fewer in one file. By the time you have done that most likely you will have figured out the problem for yourself and you will have learned a good diagnostic technique.
DWIM is Perl's answer to Gödel
| [reply] |
Ok, followup. The 'use vars' is a red herring.
package TestPm;
use strict;
use warnings;
use TestPm2;
sub foo {
print "foo\n";
}
1;
and:
package TestPm2;
use strict;
use warnings;
use TestPm;
1;
Doing a 'perl -c TestVar.pm' will spit out the Subroutine redifined error. I know its kinda circular thing, but I am really surprised perl can't handle this, so I am guessing that _I_ am not handling it correctly.
Any help would be great.
| [reply] [d/l] [select] |
Perl won't run a module twice, but when running a .pm as a script, it doesn't count as module. In other words, your module is fine. It's how you run it that's broken.
Replace
perl -c TestVar.pm
with
perl -ce "use TestPm"
to fix the problem.
However, I think there's a design problem when two modules include each other.
| [reply] [d/l] [select] |
DOH!
You know, I never actually ran it. I just do the perl -c compulisivly before I even run it. Sure enough:
#!/usr/bin/perl
use strict;
use warnings;
use TestPm;
TestPm::foo();
Works fine, no errors. Thanks a mil. | [reply] [d/l] |
| [reply] |
I was thinking of that, but not sure. I am refactoring a codebase other than mine and I am going from one 10k line .pl file to varios libs, but I don't want to go crazy.
Basically, I had a Web lib for displaying information to the user and a Storage lib for actually doing stuff like saving/getting data from persistant storage.
I wanted to pass an errorHandler subroutine reference in to the Storage funtion, but what if one wasn't provided? I wanted to have a default one use, which was in the Web package.
Its late, and I am sure you probably have better things to do, but thats my issue. I felt 3 packages excessive, but couldn't think of a cleaner way. Ultimately I made the Storage func return 0 if it had problems.
| [reply] |