thanks for the response.
However my problem is not calling the variables. but calling the module.
Let says I have this directory structure :
~myapp/class1/foo.pm
~myapp/class2/foo.pm
~myapp/class3/foo.pm
and my @INC has "~myapp/"
I wan to call :
use class?::foo; #dynamic
where class? is the variable..
e.g:
$dirname = "classX";
use $dirname::foo #error!!!
use "$dirname".::foo #error!!!
fliptop wrote:
>hkn wrote:
>
>>Can someone please tell me how I can pass variables when using "use" ?
>>
>
>create a file called SomePackage.pm:
>
>package SomePackage;
>our $var = "hello world.\n";
>1;
>__END__
>
>
>and in the cgi:
>
>#!/usr/bin/perl -w
>use strict;
>use SomePackage;
>print $SomePackage::var;
>
>
>will return
>
>hello world.
>
>
>you could also do it this way:
>
>create a file called SQL.pm:
>
>package SQL;
>sub query {
> return <<QEND;
> select foo from bar
>QEND
>}
>1;
>__END__
>
>
>and in the cgi
>
>#!/usr/bin/perl -w
>use strict;
>use SQL;
>print SQL->query();
>exit();
>
>
>this will return
>
>select foo from bar
>
>hope this helps.
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com