文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>perl写模块和用模块例子

perl写模块和用模块例子

时间:2007-12-18  来源:tonywam1036

从perl5 unleashed上抄下来的   #首先写一个模块 Letter.pm    package Letter;  require Exporter;
 @ISA = (Exporter);
   @EXPORT = qw(Date
              To
              ClaimMoney
              ClaimMoneyNice
              ThankDem
              Finish);
#------------------------------------------------------- #上面三条都是样板戏了  sub Letter::Date {
             $date = `date`;
             print "\n Today is $date";
 }
 sub Letter::To {
             local($name) = shift;
             local($subject) = shift;
             print "\n To: $name";
             print "\n Fm: Rudious Maximus, Loan Shark";
             print "\n Dt: ", `date`;
             print "\n Re: $subject";
             print "\n\n";
             print "\n====================================================\n";
 }
 sub Letter::ClaimMoney()  {
             print "\n You owe me money. Get your act together";
             print "\n Do you want me to send Bruno over to ";
             print "\n collect it , or are you gonna pay up?";
 }
 sub Letter::ClaimMoneyNice()  {
             print "\n It is come to my attention that your account is ";
             print "\n way over due.";
             print "\n You gonna pay us soon..";
             print "\n or would you like me to come ovah?";
 }
 sub Letter::ThreatBreakLeg() {
             print "\n apparently letters like these dont help";
             print "\n I will have to make an example of you";
             print "\n \n See you in the hospital, pal!";
 }
 sub Letter::ThankDem() {
             print "\n\n Thanks for your support";
 }
 sub Letter::Finish(){
             printf "\n\n\n\n Sincerely";
             printf "\n Rudious \n ";
 }
1; #最后的 1 是必须的,规定如此
#---------------------------------------------------------------------------
#上面的内容保存为Letter.pm文件   这里用模块了  #!/usr/bin/perl -w
 use Letter;
 Letter::To("Mr. Gambling Man","The money for Lucky Dog, Race 2");
 Letter::ClaimMoneyNice();
 Letter::ThankDem();
 Letter::Finish();
  date命令在windows上好像有小小问题,linux下可以。
相关阅读 更多 +
排行榜 更多 +
打螺丝高手

打螺丝高手

模拟经营 下载
解救火柴人计划安卓版

解救火柴人计划安卓版

体育竞技 下载
鸡生化精英安卓版

鸡生化精英安卓版

飞行射击 下载