zoukankan      html  css  js  c++  java
  • perl 从外部模块访问模块的函数,变量

    通常 任何未导出的仍旧可以从外部模块访问  使用YourModule::item_name 
    
    [gxp@node2 gaps]$ pwd
    /home/gxp/lib/tlcb/gaps
    
    [gxp@node2 gaps]$ cat gxpxml.pm 
    package tlcb::gasp::gxpxml;
    our $var1='asasfdasf';
    sub fun1{
       return '88888999'
    };
    1;
    
    
    [gxp@node2 ~]$ perl test.pl 
    Can't locate tlcb/gasp/gxpxml.pm in @INC (you may need to install the tlcb::gasp::gxpxml module) (@INC contains: /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux /usr/local/perl/lib/site_perl/5.22.1 /usr/local/perl/lib/5.22.1/x86_64-linux /usr/local/perl/lib/5.22.1 .) at test.pl line 1.
    BEGIN failed--compilation aborted at test.pl line 1.
    [gxp@node2 ~]$ cat test.pl 
    use tlcb::gasp::gxpxml;
    [gxp@node2 ~]$ perl test.pl 
    Can't locate tlcb/gasp/gxpxml.pm in @INC (you may need to install the tlcb::gasp::gxpxml module) (@INC contains: /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux /usr/local/perl/lib/site_perl/5.22.1 /usr/local/perl/lib/5.22.1/x86_64-linux /usr/local/perl/lib/5.22.1 .) at test.pl line 1.
    BEGIN failed--compilation aborted at test.pl line 1.
    
    
    [gxp@node2 ~]$ cat test.pl 
    BEGIN{unshift(@INC,"/home/gxp/lib");};
    use tlcb::gaps::gxpxml;
    print $tlcb::gaps::gxpxml::var1;
    print "
    ";
    print &tlcb::gaps::gxpxml::fun1;
    print "
    ";
    [gxp@node2 ~
    
  • 相关阅读:
    Leetcode Binary Tree Paths
    Leetcode Lowest Common Ancestor of a Binary Tree
    Leetcode Lowest Common Ancestor of a Binary Search Tree
    Leetcode Path Sum
    Leetcode Symmetric Tree
    Leetcode Invert Binary Tree
    Leetcode Same Tree
    Leetcode Maximum Depth of Binary Tree
    Python Json&Pickle&模块
    Python Shelve模块
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348693.html
Copyright © 2011-2022 走看看