1、配置 .htaccess
————————————
AddHandler cgi-script .cgi .pl #添加handler
Options +ExecCGI # 允许目录执行cgi
————————————
2、更改目录权限为apche apache可以执行目录下的文件
3、测试 test.cgi
——————–
#!/usr/bin/perl
print “Content-type: text/html\n\n”;
print “Hello, World.”;

若曦


这是个原版

若曦


修改1


若曦


修改2

若曦

PS:呵呵 我也贴图不说话

为灾区的人们祈福,愿灾难尽快的过去,祈祷更多的生命被救出,愿受灾的人们平安幸福
为我们受难的同胞献一份爱心
如果真的没有时间,那就发条短信吧,不要在意只有一两块钱,点滴总会汇成湖海!
“编辑短信1或2,发送至
1069999301,即向“红十字救援
行动”捐款1元钱或2元钱”

中国红十字会总会 http://redcross.org.cn
救灾专用账号和热线:
1、通过银行捐款
开户单位:中国红十字会总会
人民币开户行:中国工商银行
北京分行东四南支行
人民币账号:0200001009014413252
外币开户行:中信银行酒仙桥支行
外币账号:7112111482600000209
2、通过邮局捐款
收款人:中国红十字会总会
地址:北京市东城区北新桥三条8号
邮政编码:100007
3、通过网上捐款
登陆中国红十字会总会网站:
http://redcross.org.cn点击进入
4、通过短信捐款
中国移动、中国联通手机用户
以及中国电信、中国网通小灵通
用户均可编辑短信1或2,发送至
1069999301,即向“红十字救援
行动”捐款1元钱或2元钱。

如果你也是一个博客 加入我们为灾区祈福
feedsky祈福

,

一段用于替换字符串中指定的key的代码

–[[User:Fallseir|飞扬轻狂]] 2008年5月6日 (二) 02:32 (PDT)
$str=mapKeys($formatstr,$maps);

$str=“replace this template string !the key maps is here
key1=>{key1},key{{2=>{key{2},key3}=>{key3{}}”
;
echo 
mapKeys($str
  
,array(“key1″=>“value 1″
  
,“key{2″=>“value 2″
  
,“key3}”=>“value 3″
  
)
);
echo 
“\n”

output>>
replace this template string !the key maps is here
key1=>value 1,key{2=>value 2,key3}=>value 3
abc[the abc value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the %value% 2],%%[the %value% 2],%$$%%{,%,
abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,

$ php -r ‘highlight_file(”test.php”);’


<?php
/** test */
$str=“replace this template string !the key maps is here
key1=>{key1},key{{2=>{key{2},key3}=>{key3{}}”
;
echo 
mapKeys($str
  
,array(“key1″=>“value 1″
  
,“key{2″=>“value 2″
  
,“key3}”=>“value 3″
  
)
);
echo 
“\n”;

$str=“abc{key}{}}%{%{}%%%}%{{%{0{}%%,%%%,{key},%%,%%{key,2},%%{key,2},%$$%%{,%,”;
echo 
mapKeys($str,array(“key”=>“[the abc value]”
,“key,2″=>“[the %value% 2]”));
echo 
“\n”;

$str=“abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,”;
echo 
mapKeys($str,array(“key”=>“[the abc value]”
    
,“key,2″=>“[the %value% 2]”),“|%|”);
echo 
“\n”;
//end test*/
/*
$ php test.php
output>>
replace this template string !the key maps is here
key1=>value 1,key{2=>value 2,key3}=>value 3
abc[the abc value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the %value% 2],%%[the %value% 2],%$$%%{,%,
abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,
 
 */
 
 
/**
 * 使用maps中定义的value替换对应其key的由开始标记字符和结束标记字符包含的字符串
 *
 * 当标记对外开始标记后跟着开始标记时或结束标记时表示第一个开始标记为转义符
 * 当标记对内开始标记后跟着结束标记时表示第一个开始标记为转义符
 * 末尾没有匹配的开始标记将原样输出
 */
function mapKeys($str,$maps,$fstart=null,$fend=null){
  if(!
$fstart){
      
$fstart=“{”;
      
$fend=“}”;
  }
  if(!
$fend){
    
$fend=$fstart;    
  }
  
  
// 如果标记相同则使用mapKeysBase进行替换
  
if($fstart==$fend){return mapKeysBase($str,$maps,$fstart);}
 
  
$index=0;
  
$offset=0;
  while(
false!==($index=strpos($str,$fstart,$offset))){
    
# 找到开始标记,处理开始标记之前的数据
    
$v=substr($str,$offset,$index-$offset);
    
$offset=$index+strlen($fstart);
    
$p=true;
    while((
$find=substr($str,$offset,strlen($fstart)))==$fstart
      
||($find=substr($str,$offset,strlen($fend)))==$fend){
      
$v.=$find;
      
$offset=$offset+strlen($find);
      
$p=false;# 如果这个标记是用来转义的
      
if(false!==($index=strpos($str,$fstart,$offset))){
        
$v.=substr($str,$offset,$index-$offset);
        
$offset=$index+strlen($fstart);
        
$p=true;# 查找下一个开始标记
      
}
    }
    
$o.=$v;
    
$v=“”;
    
# 标记了开始 并找到了 结束
    
while($p
      
&&false!==($end=strpos($str,$fend,$offset))){
      
$v.=substr($str,$offset,$end-$offset);
      
# 如果这个标记是被转义的
      
if(($find=substr($str,$end-strlen($fend),strlen($fstart)))
        ==
$fstart){
        
$v=substr($v,0,strlen($v)-strlen($fstart)).$fend;
        
$offset=$end+strlen($fend);
        continue;
      }
      
$p=false;
    }
    if(
$v){
      if(
array_key_exists($v,$maps)){
        
$v=$maps[$v];
      }else{
        
$v=“[”.$v.“]”;
      }
      
$o.=$v;
      
$offset=$end+strlen($fend);
    }
  }
  if(
$p){
    
$o.=$fstart;
  }
  
$v=substr($str,$offset);
  
$o.=$v;
  return 
$o;
}
/**
 * 使用maps中定义的value替换对应其key的由标记字符包含的字符串
 *
 * 如果标记重复出现 则第一个为转义字符(这也意味着标记字符不能作为key的开始字符)
 */
function mapKeysBase($str,$maps,$find=null){
  if(!
$find){
    
$find=“%”;
  }
  
$p=false;
  
$v=“”;
  
$index=0;
  
$offset=0;
  while(
false!==($index=strpos($str,$find,$offset))){
    
$v.=substr($str,$offset,$index-$offset);
    
$offset=$index+strlen($find);
    while(
substr($str,$offset,strlen($find))==$find){
      
$v.=$find;
      
$offset=$offset+strlen($find);
      if(
false!==($index=strpos($str,$find,$offset))){
        
$v.=substr($str,$offset,$index-$offset);
        
$offset=$index+strlen($find);
      }
    }
    if(
$p){
      if(
array_key_exists($v,$maps)){
        
$v=$maps[$v];
      }else{
        
$v=“[”.$v.“]”;
      }
      
$o.=$v;
      
$v=“”;
      
$p=false;
    }else{
      
$o.=$v;
      
$v=“”;
      
$p=true;
    }
  }
  if(
$p){
    
$v.=$find;
  }
  
$v.=substr($str,$offset);
  
$o.=$v;
  return 
$o;
}
?>


取自”http://www.fallseir.com/wiki/PHP/MapKeys.html

,