码迷,mamicode.com
首页 > 其他好文 > 详细

小时代5-perl实现前后台对接的方法

时间:2014-09-15 17:22:19      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:blog   io   os   使用   java   ar   for   数据   div   

Perl“胶水”,能够将各种应用程序或者各种语言的代码结合起来。Perl可以编写普通的脚本程序,还可以使用cgi模块编写Web应用程序,同时可以使用DBI访问各种数据库。除此之外,Perl可以将各种层次的应用程序粘在一起,发挥更强大的功能。

如果前台是一个网站Web应用程序,底层或者是后台是用C,C++或者Java编写,使用Perl可以将两者对接起来,实现更强大的功能,发挥各自的优势。Perl实现该方法的途径有两个:
1) 直接在Perl脚本中嵌入别的语言编写的代码,这个可以使用Perl相关的模块,比较简单的是Inline,更能稍强但稍微复杂的是XS等。
2)另一种,是使用Perl的系统调用函数system,如:

    use strict;
    my $file="test.txt";
    system("edit $file");
    #调用dos的edit工具
    system("dir");

另一种写法:

    qx{dir};

捕获返回的结果,可以将结果赋予标量或者一个列表数组,标量的话获取结果字符的最后一样;数组的话,每个元素对应结果的每一行。
如:

    use strict;
    my @result=qx{dir};
    my $eachline;
    foreach $eachline (@result)
    {
        print "$eachline  ";
    }

还可以自己编写exe,然后由perl的system函数(或者qx)来调用。
如,可以编写一个,可给输入参数的exe程序:
main.c

    #include <stdio.h>
    #include <stdlib.h>
    int main(int argc, char **argv)
    //int main(int argc, char *argv[])
    {
        int i;
        for(i=0; i<argc; i++)
        {
                printf("%d arg is %s  ",i,argv[i]);
        }
        return 0;
    }
    //该程序的主要功能是打印出传递给main函数的各个参数。

例子:

    #!/usr/bin/perl
    use strict;
    my @result=qx{main.exe hello iam here};
    my $eachline;
    foreach $eachline (@result)
    {
        print "$eachline ";
    }

 

www.dqbky.com/gbdfzxkh
www.dqbky.com/gbdfgw
www.dqbky.com/gbdfwt
www.dqbky.com/gbdfylc
www.dqbky.com/gbdfdl
www.dqbky.com/gbdfxc
www.dqbky.com/gbdfyldl
www.dqbky.com/gbdfkhbl
www.dqbky.com/gbdfylkh
www.dqbky.com/gbylgbdf
www.dqbky.com/gggbdfylc
www.dqbky.com/gbdfsjzmdl
www.dqbky.com/gbdfylfl
www.dqbky.com/gbdfzmnyq
www.dqbky.com/gbdfyj
www.dqbky.com/gbdfxmf
www.dqbky.com/szdmdgbdf
www.dqbky.com/mdgbdf
www.dqbky.com/gbdfdhkh
www.dqbky.com/gbdfdlkh
www.dqbky.com/gbdfwtkh
www.dqbky.com/gbdfkh1581260
www.dqbky.com/gbdfylhbwz
www.dqbky.com/gbdfyq
www.dqbky.com/sygbdfyl
www.dqbky.com/gbdfylzmyq
www.dqbky.com/gbdfylyflm
www.dqbky.com/gbdfylcznl
www.dqbky.com/gbdfwz
www.dqbky.com/gbdftz
www.dqbky.com/gbdfdh
www.dqbky.com/gbdfsj
www.dqbky.com/gggbdf
www.dqbky.com/gbdfgfw
www.dqbky.com/gbdfkhw
www.dqbky.com/gbdfsh
www.dqbky.com/gbdfsjxz
www.dqbky.com/gbdfylsjxz
www.dqbky.com/gbdfwfm
www.dqbky.com/gbdfhy
www.dqbky.com/gbdfzdl
www.dqbky.com/gbdfw
www.dqbky.com/gbdfdtkmdl
www.dqbky.com/gbdfglw
www.dqbky.com/gbdfxjw
www.dqbky.com/gbdfwtkhzx
www.dqbky.com/gbdfwtdhkh
www.dqbky.com/gbdfwkh
www.dqbky.com/gbdfwthykh
www.dqbky.com/gbdftgy
www.dqbky.com/gbdfylwz
www.dqbky.com/gbdfzmzc
www.dqbky.com/gbdfbjl
www.dqbky.com/gbdfylyq
www.dqbky.com/mdgbdfrqrh
www.dqbky.com/gbdfmdyjm
www.dqbky.com/mdgbdfaqm
www.dqbky.com/gbdfxwz
www.dqbky.com/gbdfwtzx
www.dqbky.com/gbdfdms
www.dqbky.com/gbdfzc
www.dqbky.com/gbdfsy
www.dqbky.com/gbdfwzx
www.dqbky.com/gbdfzj
www.dqbky.com/gbdfdz
www.wqrfc.com/gbdf
www.wqrfc.com/gbdfkh
www.wqrfc.com/gbdfylw
www.wqrfc.com/gbdfyl
www.wqrfc.com/gbdfhykh
www.wqrfc.com/1659988_comgbdf
www.wqrfc.com/gbdfdhtz
www.wqrfc.com/gbdfylpt
www.wqrfc.com/gbdfshy
www.wqrfc.com/gbdfzxkh
www.wqrfc.com/gbdfgw
www.wqrfc.com/gbdfwt
www.wqrfc.com/gbdfylc
www.wqrfc.com/gbdfdl
www.wqrfc.com/gbdfxc
www.wqrfc.com/gbdfyldl
www.wqrfc.com/gbdfkhbl
www.wqrfc.com/gbdfylkh
www.wqrfc.com/gbylgbdf
www.wqrfc.com/gggbdfylc
www.wqrfc.com/gbdfsjzmdl
www.wqrfc.com/gbdfylfl
www.wqrfc.com/gbdfzmnyq
www.wqrfc.com/gbdfyj
www.wqrfc.com/gbdfxmf
www.wqrfc.com/szdmdgbdf
www.wqrfc.com/mdgbdf
www.wqrfc.com/gbdfdhkh
www.wqrfc.com/gbdfdlkh
www.wqrfc.com/gbdfwtkh
www.wqrfc.com/gbdfkh1581260
www.wqrfc.com/gbdfylhbwz
www.wqrfc.com/gbdfyq
www.wqrfc.com/sygbdfyl
www.wqrfc.com/gbdfylzmyq
www.wqrfc.com/gbdfylyflm
www.wqrfc.com/gbdfylcznl
www.wqrfc.com/gbdfwz
www.wqrfc.com/gbdftz
www.wqrfc.com/gbdfdh
www.wqrfc.com/gbdfsj
www.wqrfc.com/gggbdf
www.wqrfc.com/gbdfgfw
www.wqrfc.com/gbdfkhw
www.wqrfc.com/gbdfsh
www.wqrfc.com/gbdfsjxz
www.wqrfc.com/gbdfylsjxz
www.wqrfc.com/gbdfwfm
www.wqrfc.com/gbdfdtkh
www.wqrfc.com/gbdfhy
www.wqrfc.com/gbdfrhkh
www.wqrfc.com/gbdfzdl
www.wqrfc.com/gbdfw
www.wqrfc.com/gbdfdtkmdl
www.wqrfc.com/gbdfglw
www.wqrfc.com/gbdfxjw
www.wqrfc.com/gbdfwtkhzx
www.wqrfc.com/gbdfwtdhkh
www.wqrfc.com/gbdfwkh
www.wqrfc.com/gbdfwthykh
www.wqrfc.com/gbdftgy
www.wqrfc.com/gbdfylwz
www.wqrfc.com/gbdfbjl
www.wqrfc.com/mdgbdfrqrh
www.wqrfc.com/gbdfmdyjm
www.wqrfc.com/mdgbdfaqm
www.wqrfc.com/gbdfxwz
www.wqrfc.com/gbdfdms
www.wqrfc.com/gbdfzc
www.wqrfc.com/gbdfsy
www.wqrfc.com/gbdfwzx
www.wqrfc.com/gbdfzj
www.wqrfc.com/gbdfdz
www.ipnhe.com/gbdf
www.ipnhe.com/gbdfkh
www.ipnhe.com/gbdfylw
www.ipnhe.com/gbdfyl
www.ipnhe.com/gbdfhykh
www.ipnhe.com/1659988_comgbdf
www.ipnhe.com/gbdfdhtz
www.ipnhe.com/gbdfylpt
www.ipnhe.com/gbdfshy
www.ipnhe.com/gbdfzxkh
www.ipnhe.com/gbdfgw
www.ipnhe.com/gbdfwt
www.ipnhe.com/gbdfylc
www.ipnhe.com/gbdfdl
www.ipnhe.com/gbdfxc
www.ipnhe.com/gbdfyldl
www.ipnhe.com/gbdfkhbl
www.ipnhe.com/gbdfylkh
www.ipnhe.com/gbylgbdf
www.ipnhe.com/gggbdfylc
www.ipnhe.com/gbdfsjzmdl
www.ipnhe.com/gbdfylfl
www.ipnhe.com/gbdfzmnyq
www.ipnhe.com/gbdfyj
www.ipnhe.com/gbdfxmf
www.ipnhe.com/szdmdgbdf
www.ipnhe.com/mdgbdf
www.ipnhe.com/gbdfdhkh
www.ipnhe.com/gbdfdlkh
www.ipnhe.com/gbdfwtkh
www.ipnhe.com/gbdfkh1581260
www.ipnhe.com/gbdfylhbwz
www.ipnhe.com/gbdfyq
www.ipnhe.com/sygbdfyl
www.ipnhe.com/gbdfylzmyq
www.ipnhe.com/gbdfylyflm
www.ipnhe.com/gbdfylcznl
www.ipnhe.com/gbdfwz
www.ipnhe.com/gbdftz
www.ipnhe.com/gbdfdh
www.ipnhe.com/gbdfsj
www.ipnhe.com/gggbdf
www.ipnhe.com/gbdfgfw
www.ipnhe.com/gbdfkhw
www.ipnhe.com/gbdfsh
www.ipnhe.com/gbdfsjxz
www.ipnhe.com/gbdfylsjxz
www.ipnhe.com/gbdfwfm
www.ipnhe.com/gbdfdtkh
www.ipnhe.com/gbdfhy
www.ipnhe.com/gbdfrhkh
www.ipnhe.com/gbdfzdl
www.ipnhe.com/gbdfw
www.ipnhe.com/gbdfdtkmdl
www.ipnhe.com/gbdfglw
www.ipnhe.com/gbdfxjw
www.ipnhe.com/gbdfwtkhzx
www.ipnhe.com/gbdfwtdhkh
www.ipnhe.com/gbdfwkh
www.ipnhe.com/gbdfwthykh
www.ipnhe.com/gbdftgy
www.ipnhe.com/gbdfzmzc
www.ipnhe.com/gbdfbjl
www.ipnhe.com/gbdfylyq
www.ipnhe.com/mdgbdfrqrh
www.ipnhe.com/gbdfmdyjm
www.ipnhe.com/mdgbdfaqm
www.ipnhe.com/gbdfkmdl
www.ipnhe.com/gbdfxwz
www.ipnhe.com/gbdfwtzx
www.ipnhe.com/gbdfdms
www.ipnhe.com/gbdfzc
www.ipnhe.com/gbdfsy
www.ipnhe.com/gbdfwzx
www.ipnhe.com/gbdfnyqb
www.ipnhe.com/gbdfzj
www.ipnhe.com/gbdfdz
www.vwnwu.com/gbdf
www.vwnwu.com/gbdfkh
www.vwnwu.com/gbdfylw
www.vwnwu.com/gbdfyl
www.vwnwu.com/gbdfhykh
www.vwnwu.com/1659988_comgbdf
www.vwnwu.com/gbdfdhtz
www.vwnwu.com/gbdfylpt
www.vwnwu.com/gbdfshy
www.vwnwu.com/gbdfzxkh
www.vwnwu.com/gbdfgw
www.vwnwu.com/gbdfwt
www.vwnwu.com/gbdfylc
www.vwnwu.com/gbdfdl
www.vwnwu.com/gbdfxc
www.vwnwu.com/gbdfyldl
www.vwnwu.com/gbdfkhbl
www.vwnwu.com/gbdfylkh
www.vwnwu.com/gbylgbdf
www.vwnwu.com/gggbdfylc
www.vwnwu.com/gbdfsjzmdl
www.vwnwu.com/gbdfylfl
www.vwnwu.com/gbdfzmnyq
www.vwnwu.com/gbdfyj
www.vwnwu.com/gbdfxmf
www.vwnwu.com/szdmdgbdf
www.vwnwu.com/mdgbdf
www.vwnwu.com/gbdfdhkh
www.vwnwu.com/gbdfdlkh
www.vwnwu.com/gbdfwtkh
www.vwnwu.com/gbdfkh1581260
www.vwnwu.com/gbdfylhbwz
www.vwnwu.com/gbdfyq
www.vwnwu.com/sygbdfyl
www.vwnwu.com/gbdfylzmyq
www.vwnwu.com/gbdfylyflm
www.vwnwu.com/gbdfylcznl
www.vwnwu.com/gbdfwz
www.vwnwu.com/gbdftz
www.vwnwu.com/gbdfdh
www.vwnwu.com/gbdfsj
www.vwnwu.com/gggbdf
www.vwnwu.com/gbdfgfw
www.vwnwu.com/gbdfkhw
www.vwnwu.com/gbdfsh
www.vwnwu.com/gbdfsjxz
www.vwnwu.com/gbdfylsjxz
www.vwnwu.com/gbdfwfm
www.vwnwu.com/gbdfdtkh
www.vwnwu.com/gbdfhy
www.vwnwu.com/gbdfrhkh
www.vwnwu.com/gbdfzdl
www.vwnwu.com/gbdfw
www.vwnwu.com/gbdfdtkmdl
www.vwnwu.com/gbdfglw
www.vwnwu.com/gbdfxjw
www.vwnwu.com/gbdfwtkhzx
www.vwnwu.com/gbdfwtdhkh
www.vwnwu.com/gbdfwkh
www.vwnwu.com/gbdfwthykh
www.vwnwu.com/gbdftgy
www.vwnwu.com/gbdfylwz
www.vwnwu.com/gbdfzmzc
www.vwnwu.com/gbdfbjl
www.vwnwu.com/gbdfylyq
www.vwnwu.com/mdgbdfrqrh
www.vwnwu.com/gbdfmdyjm
www.vwnwu.com/mdgbdfaqm
www.vwnwu.com/gbdfkmdl
www.vwnwu.com/gbdfxwz
www.vwnwu.com/gbdfwtzx
www.vwnwu.com/gbdfdms
www.vwnwu.com/gbdfzc
www.vwnwu.com/gbdfsy
www.vwnwu.com/gbdfwzx
www.vwnwu.com/gbdfnyqb
www.vwnwu.com/gbdfzj
www.vwnwu.com/gbdfdz
www.rqzzk.com/gbdf
www.rqzzk.com/gbdfkh
www.rqzzk.com/gbdfylw
www.rqzzk.com/gbdfyl
www.rqzzk.com/1659988_comgbdf
www.rqzzk.com/gbdfdhtz
www.rqzzk.com/gbdfylpt
www.rqzzk.com/gbdfshy
www.rqzzk.com/gbdfzxkh
www.rqzzk.com/gbdfgw
www.rqzzk.com/gbdfwt
www.rqzzk.com/gbdfylc
www.rqzzk.com/gbdfdl
www.rqzzk.com/gbdfxc
www.rqzzk.com/gbdfyldl
www.rqzzk.com/gbdfkhbl
www.rqzzk.com/gbdfylkh
www.rqzzk.com/gbylgbdf
www.rqzzk.com/gggbdfylc
www.rqzzk.com/gbdfsjzmdl
www.rqzzk.com/gbdfylfl
www.rqzzk.com/gbdfzmnyq
www.rqzzk.com/gbdfyj
www.rqzzk.com/gbdfxmf
www.rqzzk.com/szdmdgbdf
www.rqzzk.com/mdgbdf
www.rqzzk.com/gbdfdhkh
www.rqzzk.com/gbdfdlkh
www.rqzzk.com/gbdfwtkh
www.rqzzk.com/gbdfkh1581260
www.rqzzk.com/gbdfylhbwz
www.rqzzk.com/gbdfyq
www.rqzzk.com/gbdfylzmyq
www.rqzzk.com/gbdfylyflm
www.rqzzk.com/gbdfylcznl
www.rqzzk.com/gbdfwz
www.rqzzk.com/gbdftz
www.rqzzk.com/gbdfdh
www.rqzzk.com/gbdfsj
www.rqzzk.com/gggbdf
www.rqzzk.com/gbdfgfw
www.rqzzk.com/gbdfkhw
www.rqzzk.com/gbdfsh
www.rqzzk.com/gbdfsjxz
www.rqzzk.com/gbdfylsjxz
www.rqzzk.com/gbdfwfm
www.rqzzk.com/gbdfdtkh
www.rqzzk.com/gbdfhy
www.rqzzk.com/gbdfrhkh
www.rqzzk.com/gbdfzdl
www.rqzzk.com/gbdfw
www.rqzzk.com/gbdfdtkmdl
www.rqzzk.com/gbdfglw
www.rqzzk.com/gbdfxjw
www.rqzzk.com/gbdfwtkhzx
www.rqzzk.com/gbdfwtdhkh
www.rqzzk.com/gbdfwkh
www.rqzzk.com/gbdfwthykh
www.rqzzk.com/gbdftgy
www.rqzzk.com/gbdfylwz
www.rqzzk.com/gbdfzmzc
www.rqzzk.com/gbdfbjl
www.rqzzk.com/gbdfylyq
www.rqzzk.com/mdgbdfrqrh
www.rqzzk.com/gbdfmdyjm
www.rqzzk.com/mdgbdfaqm
www.rqzzk.com/gbdfkmdl
www.rqzzk.com/gbdfxwz
www.rqzzk.com/gbdfwtzx
www.rqzzk.com/gbdfdms
www.rqzzk.com/gbdfzc
www.rqzzk.com/gbdfsy
www.rqzzk.com/gbdfwzx
www.rqzzk.com/gbdfnyqb
www.rqzzk.com/gbdfzj
www.rqzzk.com/gbdfdz
www.cjjhl.com/gbdf
www.cjjhl.com/gbdfkh
www.cjjhl.com/gbdfylw
www.cjjhl.com/gbdfyl
www.cjjhl.com/gbdfhykh
www.cjjhl.com/1659988_comgbdf
www.cjjhl.com/gbdfdhtz
www.cjjhl.com/gbdfylpt
www.cjjhl.com/gbdfshy
www.cjjhl.com/gbdfzxkh
www.cjjhl.com/gbdfgw
www.cjjhl.com/gbdfwt
www.cjjhl.com/gbdfylc
www.cjjhl.com/gbdfdl
www.cjjhl.com/gbdfxc
www.cjjhl.com/gbdfyldl

 

小时代5-perl实现前后台对接的方法

标签:blog   io   os   使用   java   ar   for   数据   div   

原文地址:http://www.cnblogs.com/perl2014/p/3973179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!