Reputation: 21
A brief overview of each module. (I'm assuming this is the right way to add more information to my post. Apologizes as this is the first time i'm posting)
A.pm - Contains re-usable routines to read the ZIP file, decrypt the content, validations etc., (Used by various CGI files, command line scripts and other Perl modules)
B.pm - This is the Utils file, which connects to DB, all the SQLs related subroutines, invokes C.pm to write marks into each file
C.pm - Specialized routine to mark each file within ZIP similar to a checksum (checks for file types allowed, read files, write files, examine etc.,), Uses A.pm because the module needs to decrypt content, perform validations done by A.pm
Including some sample code (i'm just posting few use lines here; obviously lot of modules are being used in .pm)
A.pm
package A;
use strict;
use warnings;
use B;
..........
B::get_database_information_for_file(..)
..........
sub validate_decrypted_mark { ...... }
sub decrypt_mark {..........}
.....
B.pm
package B;
use strict;
use warnings;
use C;
..........
C::mark_file(..)
..........
sub db_connect { ...... }
sub get_database_information_for_file {..........}
.....
C.pm
package C;
use strict;
use warnings;
use A;
..........
A::decrypt_mark(..)
..........
sub mark_file { ...... }
sub read_mark {..........}
sub write_mark {..........}
sub examine_mark {..........}
.....
Few more additional information (which could be useful)
These warnings are showing up when we recently moved from Solaris/Apache to LAMP.
We use mod_perl, so it could be possible that the module is already in memory?
=====
Hello,
I've searched on Stack Overflow and found the root cause for my issue.
But i have a different situation than the one specified in above thread. My issue is, i get subroutine redefined error in Perl (same as the one specified in the above thread). But my question is around the circular reference and/or best practices. I've the following scenario, which is leading to subroutine redefined warning
Package A --uses-> Package B --uses-> Package C --uses-> Package A
Since Package C uses Package A, obviously i will redefined subroutine warning. But my question is, is this a bad programming practice to do this way? What are the thoughts from the best practices angle?
I cannot avoid this references as Package C need to use the subroutines defined in Package A. "Grant McLean" had a very good suggestion in the above thread for my situation given above. I wouldn't want to avoid these warnings as these could indicate some issues.
Really appreciate your time and help.
Thanking you,
Upvotes: 2
Views: 5236
Reputation: 98423
Circular use shouldn't generally give you a subroutine redefined warning, unless you directly execute one of the packages instead of doing use/require. Sometimes people try to do syntax checking this way:
perl -c Foo.pm
Instead, they should do
perl -e'use Foo'
So can you share exactly what you are doing to provoke the subroutine redefined warnings?
Upvotes: 5