wrote:
> Hello,
>
> Description:
>
> package A;
> my $instance;
> sub new {
> my $class = shift;
> my %args = @_;
> return $instance if $instance;
> . . . stuff appropriate args into $instance ...
## Don't say it in English with ". . ." when you can say it in Perl.
$instance={%args};
## It is shorter, clearer, and allows us to run the code.
> return bless $instance, $class;
> }
> . . .
1;
>
> package B;
> use A;
> our @ISA = qw(A);
> __PACKAGE_->SUPER::new(some args);
You are missing an "_" from __PACKAGE__.
There is already a module named B. Choose something
else for your example.
> . . .
>
> package XYZ;
> use A;
> my $o = new A;
> . . .
>
> Now using them
>
> 1 - This will work
> #!/usr/bin/perl -w
> use strict;
> use B;
> use XYZ;
> ....
>
> 2 - This won't work
> #!/usr/bin/perl -w
> use strict;
> use XYZ;
> use B; <= this won't work
It does "work", it just doesn't read your mind.
> ....
>
> Since in XYZ the singleton $o is actually instantiated with appropriate
> parameters by the line __PACKAGE__->SUPER::new in B, the order of
> module loading in 1) will work while that in 2) won't as 'use' implies
> BEGIN blocks in FIFO.
>
> Question: is there a way to ensure that a certain module is always
> loaded before other modules no matter where it is with "use".
I'm sure there is, but I doubt it is a very good way. perls needs to know
which module you wanted loaded first--it can't just read your mind. I'm
sure you could come up with some ackward way of telling it that using
source filters or such, but why not use "use" to tell it this?
Xho
--
--------------------
http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB