技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

perl杂记

函数

#! /usr/bin/perl

#传参测试
sub hello
{
    print $_[0];
}

&hello("hello,world\n");

#返回值测试
sub max
{
    if ($_[0] > $_[1])
    {
        return $_[0];
    }
    else
    {
        return $_[1];
    }
}

$n = &max(10,23);
prin}
test(

 模拟函数指针

#! /usr/bin/perl

sub hello
{
    print $_[0];
}

&hello("hello,world\n");

#模拟函数指针的测试
@funcPointer = (\&hello);
$funcPointer[0]->("testing...\n");

 

posted on 2013-04-02 11:53  codestyle  阅读(169)  评论(0)    收藏  举报