技术宅,fat-man

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

导航

2013年4月2日 #

perl函数指针

摘要: 看来的代码,测试通过#!/usr/bin/perlsub func1 { print "func1 is running\n";}sub func_test { my $func_ref = shift; # ref will return 'CODE' if it's function reference if ( ( ref($func_ref) eq "CODE" ) && defined( &{$func_ref} ) ) { &{$func_ref}; print $@ if $@; } 阅读全文

posted @ 2013-04-02 13:18 codestyle 阅读(673) 评论(0) 推荐(0)

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/perlsub hello{ print $_[0];}&hello("hello,world\n");#模拟函数指针的测试@funcPoi... 阅读全文

posted @ 2013-04-02 11:53 codestyle 阅读(169) 评论(0) 推荐(0)

awk学习杂记

摘要: #! /bin/sh#awk '{ print }' /etc/passwd#awk -F":" '{ print $1 }' /etc/passwdawk 'BEGIN{testArray["a"]="aaa";testArray["b"]="bbb"}function test(){ #print $1; print testArray["a"] print testArray["b"]}test();END{p 阅读全文

posted @ 2013-04-02 09:51 codestyle 阅读(116) 评论(0) 推荐(0)