Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29019373
  • 博文数量: 101
  • 博客积分: 4011
  • 博客等级: 上校
  • 技术积分: 1150
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-18 10:37
个人简介

落魄青年,挨踢民工,已经转行

文章分类

全部博文(101)

文章存档

2008年(47)

2007年(54)

分类:

2007-12-18 16:07:31

从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下可以。
阅读(2479) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~