2009年6月5日星期五

[PerlChina] Re: 如何用变量代替包名来调用包的函数?

Oh,
$mod->header();

-_-!

2009/6/5 silent <silent2600@gmail.com>:
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use CGI qw/:standard/;
>
> my $mod = "CGI";
>
> #print CGI::header, "\n"; 不用这个方法,因为包名可能是动态载入的
> print $mod::header(), "\n";
>
>
>
> % perl mod.pl
> Name "mod::header" used only once: possible typo at mod.pl line 11.
> Can't use an undefined value as a symbol reference at mod.pl line 11.
>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: