Chinaunix首页 | 论坛 | 博客
  • 博客访问: 467696
  • 博文数量: 142
  • 博客积分: 4126
  • 博客等级: 上校
  • 技术积分: 1545
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-22 10:03
文章分类

全部博文(142)

文章存档

2011年(8)

2010年(7)

2009年(64)

2008年(63)

我的朋友

分类:

2008-11-19 14:46:38

完成
制作网页的最后的要求是页面外观的美观,遗憾的是,HTML::TreeBuilder或任何相关的模组都不能帮助完成对这个要求的评分,所以,本文的作者只能自己手动给最后一个要求评分。但是他有希望用perl在这项工作上帮点忙,所以就有了下面的一段代码:

my $input = "";
do {
    print "$str1 [$str2]: ";
    $input = <STDIN>;
    $input =~ s/(^\s+|\s+$)//g;
} until ( $input =~ /(.*\.\s+\d+$|^\s*$|^\d+$)/ );

$input = $str2 if $input eq "";
if ( $input =~ /^\d+$/ ) {
    $n = $input;
    if ( $n == 10 ) {
        $input = "good looking, nice content. $n";
    }
    else {
        ( $input = $str2 ) =~ s/(\.\s*)\d+\s*$/$1$n/;
    }
}
marking "$str1 $input";

最后,perl代码为每一个要求标记出包含老师的注释和评分的文本并且计算出整个作业的总成绩。

 

my ( $total, $score ) = ( 0, 0 );
while ( $marktext =~ /.*?\((\d+)\s+points\).*?\.\s+(\d+)/g )
{
    $total += $1;
    $score += $2;
}
marking "Total ($total points): $score";

阅读(613) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~