“php perl ruby”目录存档

zend studio打不开页面

2010年08月29日,星期天

今天想试一下zend studio, 在官方网下载好在win7下安装后,发现zend server其实就是apache, zend studio就是扩展了eclipse,但zend server/studio却还要收钱,真不知道是怎么遵守开源协议的。

创建一个test项目后,结果页面都打不开,返回的错误是这样的:Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

花了不少时间看它们配置,发现配置都没什么问题,有点恼火啊,功夫不负有心人,原来这个文件Zend\ZendServer\etc\ZendEnablerConf.xml 第一行出现了乱码:锘??xml version=”1.0″ encoding=”UTF-8″?>
把它改为:<?xml 就行了

install_driver(Oracle) failed: Can’t load `…/DBD/Oracle/Oracle.so’ for module DBD::Oracle

2010年04月15日,星期四

Description

This section is from the "Practical mod_perl " book, by Stas Bekman and Eric Cholet . Also available from Amazon: Practical mod_perl

Here’s an example of the full error report that you might see:

install_driver(Oracle) failed: Can't load

'/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/Oracle/Oracle.so'

for module DBD::Oracle:

libclntsh.so.8.0: cannot open shared object file: 

No such file or directory at

/usr/lib/perl5/5.6.1/i386-linux/DynaLoader.pm line 169.

at (eval 27) line 3

Perhaps a required shared

library or dll isn't installed where expected at 

/usr/local/apache/perl/tmp.pl line 11


 

On BSD-style filesystems, LD_LIBRARY_PATH is not searched for setuid programs. If Apache is a setuid executable, you might receive this error. Therefore, the first solution is to explicitly load the library from the system-wide ldconfig configuration file:

panic# echo $ORACLE_HOME/lib >> /etc/ld.so.conf

panic# ldconfig

(使用该方法我的问题就解决了)

Another solution to this problem is to modify the Makefile file (which is created when you run perl Makefile.PL ) as follows:

  1. Search for the line LD_RUN_PATH=

  2. Replace it with LD_RUN_PATH=my_oracle_home/lib

where my_oracle_home is, of course, the home path to your Oracle installation. In particular, the file libclntsh.so.8.0 should exist in the lib subdirectory.

Then just type make install , and all should go well.

Note that setting LD_RUN_PATH has the effect of hardcoding the path to my_oracle_home/lib in the file Oracle.so , which is generated by DBD::Oracle . This is an efficiency mechanism, so that at runtime it doesn’t have to search through LD_LIBRARY_PATH or the default directories used by ld.

For more information, see the ld manpage and the essay on LD_LIBRARY_PATH at http://www.visi.com/~barr/ldpath.html .

Perl String Comparison Operators

2010年04月6日,星期二

In order to compare for string equality, or if one string is alphabetically bigger than another, you can use the six string comparison operators. Here are the string operators together with the numerical operators they correspond too:

String Operator Numerical Operator
eq ==
ne !=
gt >
lt <
ge >=
le <=

Notice that the string operators are built from the initials of their abbreviated names. (E.g: eq = equal, gt = greater than). Perl’s string comparison is case-sensitive. If you want a case insensitive string comparison, use the lc function to convert the strings to lowercase beforehand.

Do not throw exception in exception_handler function and __destruct without try-catch

2010年03月31日,星期三
Do NOT throw exception in exception_handler function, if you do it like below, 
the error “Fatal error: Exception thrown without a stack frame in Unknown on line 
0” will occur
set_exception_handler('handle_exception');
function handle_exception($e)
{
    throw new Exception('throwed in handle_exception');
}
throw new Exception('error occur');

if you try-catch the Exception in exception_handler function, it will be ok, the below code will work well

set_exception_handler('handle_exception');
function handle_exception($e)
{
    try {
        throw new Exception('throwed in handle_exception');
    }
    catch (Exception $e) {
        die('catch exception in handle_exception function');
    }
}
throw new Exception('error occur');
Do NOT throw Exception in __destruct like below, or “Fatal error: Exception thrown
without a stack frame in Unknown on line 0” will occur.
class Test {
    function __construct () {}
    function __destruct() {
        throw new Exception('throwed in __destruct');
    }
}
$test = new Test();

but it will work well when try-catch it like below

class Test {
    function __construct () {}
    function __destruct() {
        try {
            throw new Exception('throwed in __destruct');
        }
        catch (Exception $e) {
            die('catch exception in __destruct');
        }

    }
}
$test = new Test();

ruby版本的discuz自动注册机

2009年12月29日,星期二

概要:
为了让别人以为你discuz网站的注册用户比较多,你可能需要注册大量虚假用户来伪造discuz网站的人气,如果手动地注册,那效率肯定会很低,势必需要一个工具来帮我们自动化地完成这个工作,本人就用ruby写了这样一个自动为discuz注册用户的工具.
(全文…)