books translated by others
Intermediate Perl (Chapter 1,2 for now), is translated by allexit in LinuxSir
I'm trying to translate the Perl 6 Syn again since old ones are somehow outdated.
Welcome to join us in PerlChina GoogleCode.
Perl is not the whole part of life. I know!
# Root.pm如果有其他 pm 的 sub end 覆盖了 Root.pm 的 end 的话,那还要在那个
sub begin : Private { my ($self, $c) = @_; $c->stash->{start_t0} =
[gettimeofday]; }
sub end : Private { my ($self, $c) = @_;
if ($c->res->body || $c->res->location) {
$c->model('Log')->log_path($c, tv_interval(
$c->stash->{start_t0}, [gettimeofday] ) ); # log path
return;
}
# code here
$c->forward($c->view('TT'));
$c->model('Log')->log_path($c, tv_interval( $c->stash->{start_t0},
[gettimeofday] ) ); # log path
}
package Catalyst::Action::PathLogger;而 Root.pm 的 sub end 将不在用 :Private 而是 sub end :
use strict;use warnings;
use base 'Catalyst::Action';
use Time::HiRes qw( gettimeofday tv_interval );
sub execute {
my $self = shift;
my ( $controller, $c ) = @_;
$self->NEXT::execute( @_ );
$c->model('Log')->log_path($c, tv_interval( $c->stash->{start_t0},
[gettimeofday] ) );
}
Labels: Catalyst
captcha:然后弄一个 captcha 的 Global 函数。
session_name: captcha_string
new:
width: 80
height: 30
lines: 1
gd_font: giant
create:
- normal
- rect
particle:
- 100
out:
force: jpeg
sub captcha : Global {
my ($self, $c) = @_;
$c->create_captcha();
}create_captcha 返回的是一个 img 的 source, 也就是验证码那个图片的内容。<input type='text' name='captcha' size='12' /><img src='/captcha' />img 的地址就是刚才的 Global 所弄的函数。插件将这个图片实际上的字符串内容放到了当前的 session 里。
$c->session->{ $c->config->{captcha}->{session_name} } = $random_string;然后它提供的 validate_captcha method 就是比较 user 输入的东西跟这个 session 的内容。看看源代码就觉得非常清晰。Labels: Catalyst
Labels: javascript, scriptaculous
works fine in my WinXP, and with great Cache::Memcached in CPAN.