P
perlguru
This is with respect to a thread "Use different modules based on
variable" <http://groups.google.com/group/comp.lang.perl.misc/
browse_thread/thread/00b9efe4f4416943?tvc=2> .
In this I had suggested for making use of 'require', but that
suggestion was bounced back very badly.
Recently I gave a try, and I see that my suggestion is working :
I created 1st Module 1.1/Test.pm :-
----------------------------------------------------
package Test;
sub func{
print "In 1.1/ \n";
return 1;
}
1;
Created another Module 2.2/Test.pm :-
-----------------------------------------------------------
package Test;
sub func{
print "In 2.2 \n";
return 1;
}
1;
The Main program :-
--------------------------------
#!/usr/bin/perl
$ver=$ARGV[0];
if ( $ver eq '1.1' ){
require "./1.1/Test.pm";
Test::func();
require "./2.2/Test.pm";
Test::func();
}else{
require "./2.2/Test.pm";
Test::func();
require "./1.1/Test.pm";
Test::func();
}
Test::func();
exit 0;
After I executed :-
--------------------------------
$ perl test.pl 1.1
In 1.1/
In 2.2
In 2.2
$ perl test.pl 2.2
In 2.2
In 1.1/
In 1.1/
$ perl test.pl
In 2.2
In 1.1/
In 1.1/
------------End----------------------
I am just a user of Perl, and don't have indepth idea about its
design, And the way its interpreter works.
Would like to know your views, on how is above thing working?
What is dispatch table? And
Why as the per discussion thread
http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/00b9efe4f4416943?tvc=2
it shouldnt have been working ?
variable" <http://groups.google.com/group/comp.lang.perl.misc/
browse_thread/thread/00b9efe4f4416943?tvc=2> .
In this I had suggested for making use of 'require', but that
suggestion was bounced back very badly.
Recently I gave a try, and I see that my suggestion is working :
I created 1st Module 1.1/Test.pm :-
----------------------------------------------------
package Test;
sub func{
print "In 1.1/ \n";
return 1;
}
1;
Created another Module 2.2/Test.pm :-
-----------------------------------------------------------
package Test;
sub func{
print "In 2.2 \n";
return 1;
}
1;
The Main program :-
--------------------------------
#!/usr/bin/perl
$ver=$ARGV[0];
if ( $ver eq '1.1' ){
require "./1.1/Test.pm";
Test::func();
require "./2.2/Test.pm";
Test::func();
}else{
require "./2.2/Test.pm";
Test::func();
require "./1.1/Test.pm";
Test::func();
}
Test::func();
exit 0;
After I executed :-
--------------------------------
$ perl test.pl 1.1
In 1.1/
In 2.2
In 2.2
$ perl test.pl 2.2
In 2.2
In 1.1/
In 1.1/
$ perl test.pl
In 2.2
In 1.1/
In 1.1/
------------End----------------------
I am just a user of Perl, and don't have indepth idea about its
design, And the way its interpreter works.
Would like to know your views, on how is above thing working?
What is dispatch table? And
Why as the per discussion thread
http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/00b9efe4f4416943?tvc=2
it shouldnt have been working ?