由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Perl queston, can I require the module dynamically?
相关主题
Quick Question about perl module说个Perl无与伦比?的优点吧
Anybody using Python?一切用dynamic typing的语言写大系统都是耍流氓
精通perl的人都是从事什么工作的?如何确认perl 里安装了json module
请问, 有这样的perl module 吗请教perl的tainted和cgi::param()
script language主要是干什么用的?remove a module from cvs
[合集] perl 下面 TLS/SSL IMAP module??damn, love vert.x
dynamic本身没有错问个Python的问题
clojure这种东西只能自己一个人单干Dynamic buffer management question
相关话题的讨论汇总
话题: module话题: perl话题: require话题: queston话题: alias
进入Programming版参与讨论
1 (共1页)
F*******i
发帖数: 190
1
Can I ask perl to local the module dependent on the command line
argument inptu? such ash
./binperl --module=mod
in the binperl.pl
you can dynamiclly load the module mod and call a function
mod::function()?
Thanks!
r****t
发帖数: 10904
2
probably you can, but I have no idea how... would
if ... require ...
simply work?
F*******i
发帖数: 190
3
seems not to me.

【在 r****t 的大作中提到】
: probably you can, but I have no idea how... would
: if ... require ...
: simply work?

t****t
发帖数: 6806
4
perl -Mmodule binperl
on command line
or if you prefer to do it inside the program, "require" is actually a
function

【在 F*******i 的大作中提到】
: Can I ask perl to local the module dependent on the command line
: argument inptu? such ash
: ./binperl --module=mod
: in the binperl.pl
: you can dynamiclly load the module mod and call a function
: mod::function()?
: Thanks!

F*******i
发帖数: 190
5
Thank you very much for your hint.
Didn't figure out how to use require to achieve this goal.
Here is my problem:
./mybinary.pl --module=modA
or
./mybinary.pl --module=modB
I would like to use the symbol in modA or modB conditional on the argument
input.
such as in mybinary.pl:
I'd like:
if $module eq "modA"
require $module;
$module::function() does not work,
The other question is: is there any way to make a alias to $module,
that I can use

【在 t****t 的大作中提到】
: perl -Mmodule binperl
: on command line
: or if you prefer to do it inside the program, "require" is actually a
: function

t****t
发帖数: 6806
6
I am not sure how to alias an entire module (I read through the document and
did some test, seems not work). But you can definitely alias a few
functions, such as:
require POSIX;
local *alias::floor = \&POSIX::floor;
alias::floor(0.5);

【在 F*******i 的大作中提到】
: Thank you very much for your hint.
: Didn't figure out how to use require to achieve this goal.
: Here is my problem:
: ./mybinary.pl --module=modA
: or
: ./mybinary.pl --module=modB
: I would like to use the symbol in modA or modB conditional on the argument
: input.
: such as in mybinary.pl:
: I'd like:

S**********t
发帖数: 457
7
try UNIVERSAL::require
F*******i
发帖数: 190
8
Thank you! It will be great if perl support alias for (package/modue).

and

【在 t****t 的大作中提到】
: I am not sure how to alias an entire module (I read through the document and
: did some test, seems not work). But you can definitely alias a few
: functions, such as:
: require POSIX;
: local *alias::floor = \&POSIX::floor;
: alias::floor(0.5);

F*******i
发帖数: 190
9
Thank you,
will have a try.

【在 S**********t 的大作中提到】
: try UNIVERSAL::require
1 (共1页)
进入Programming版参与讨论
相关主题
Dynamic buffer management questionscript language主要是干什么用的?
[合集] 问个题--- web dynamic graphic generation[合集] perl 下面 TLS/SSL IMAP module??
backend language of choicedynamic本身没有错
大家看过来Re: C++ Guys!!!!clojure这种东西只能自己一个人单干
Quick Question about perl module说个Perl无与伦比?的优点吧
Anybody using Python?一切用dynamic typing的语言写大系统都是耍流氓
精通perl的人都是从事什么工作的?如何确认perl 里安装了json module
请问, 有这样的perl module 吗请教perl的tainted和cgi::param()
相关话题的讨论汇总
话题: module话题: perl话题: require话题: queston话题: alias