标题: 用户数据集中写入
问天
元帅
Rank: 1


元帅勋章 终身成就勋章
UID 11493
精华 187
积分 34201
帖子 33353
威望 91
金币 13148
热心 2617
阅读权限 100
注册 2006-4-7
状态 在线
用户数据集中写入

代码:
--------------------------------------------------------------------------------   
sub upmemberdate {
my $membernametemp = shift;
my %userinfo = @_;

   
my $filetoopen = "$lbdir$memdir/$membernametemp.cgi";
if (-e $filetoopen) {
open (FILE,$filetoopen);
my $filedata=<FILE>;
close(FILE);
chomp $filedata;
local ( $membername, $password, $membertitle, $membercode, $numberofposts, $emailaddress, $showemail, $ipaddress, $homepage, $oicqnumber, $icqnumber, $location, $interests, $joineddate, $lastpostdate, $signature, $timedifference, $privateforums, $useravatar, $userflag, $userxz, $usersx, $personalavatar, $personalwidth, $personalheight, $rating, $lastgone, $visitno, $addjy, $meili, $mymoney, $postdel, $sex, $education, $marry, $work, $born, $chatlevel, $chattime, $jhmp, $useradd3, $useradd4, $onlinetime, $userquestion, $useradd6, $useradd7, $useradd8) = split(/\t/,$filedata);
local($numberofposts,$numofreplys)=split(/\|/,$numberofposts);
foreach my $info (keys %userinfo) {
if ($userinfo{$info}="/^[\ \-][0-9] $/) {
$$info  = $userinfo{$info};
}
else {
$userinfo{$info} =" s/^\\(\-|\ )/$1/;
$userinfo{$info} =" s/^\\\\/\\/;  
$$info = $userinfo{$info};
}
#print "$info $$info\n";
}
open(FILE,">$filetoopen");
print FILE "$membername\t$password\t$membertitle\t$membercode\t$numberofposts\|$numberofreplys\t$emailaddress\t$showemail\t$ipaddress\t$homepage\t$oicqnumber\t$icqnumber\t$location\t$interests\t$joineddate\t$lastpostdate\t$signature\t$timedifference\t$privateforums\t$useravatar\t$userflag\t$userxz\t$usersx\t$personalavatar\t$personalwidth\t$personalheight\t$rating\t$lastgone\t$visitno\t$addjy\t$meili\t$mymoney\t$postdel\t$sex\t$education\t$marry\t$work\t$born\t$chatlevel\t$chattime\t$jhmp\t$useradd3\t$useradd4\t$onlinetime\t$userquestion\t$useradd6\t$useradd7\t$useradd8\t\n";
close(FILE);
}
}


   
所传递的参数,第一个是所要写入的用户名,后面是一个哈希表,哈希表的关键字是要被改变的变量名,值是增减的值或被改为的值。
如果哈希表的值以   - 开头,则是对相应的用户数据增减,否则就将相应的用户数据设为哈希表的值。
如果要将一个以   - 开头的字串付给一个变量的话,就要用 \ 对其进行一次转义,如果以 \ 开头还要进行一次转义。
例如,将用户 test 的发贴数加1 ,威望设为 -6 ,可以这样调用过程。
&;amp;upmemberdate('test',numofposts,' 1',rating,'\-6');

网友 问天 签名 - 网友社区 请您回个帖。谢谢
PR查询 免费域名 免费空间
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-11 19:08
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP