This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for my $field (qw(type nph expires cookie charset attachment p3p)) { | |
| my $slot = __PACKAGE__."::$field"; | |
| my $code = sub { | |
| my $self = shift; | |
| my $value = shift; | |
| if ($value) { | |
| $self->set($field => $value); | |
| } | |
| else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # $value = get_header( $blosxom::header, 'foo' ); | |
| # $bool = exists_header( $blosxom::header, 'foo' ); | |
| # set_header( $blosxom::header, 'foo' => 'bar' ); | |
| # remove_header( $blosxom::header, 'foo' ); | |
| for my $method ( qw(get set remove exists) ) { | |
| my $slot = __PACKAGE__ . "::${method}_header"; | |
| my $code = sub { | |
| my ( $header_ref, @args ) = @_; | |
| __PACKAGE__->new( $heaeder_ref )->$method( @args ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Blosxom::Header::Prototype; | |
| use strict; | |
| use warnings; | |
| use Carp; | |
| use Scalar::Util qw(refaddr); | |
| { | |
| my %prototype_of; | |
| sub can { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Blosxom::Header::Object; | |
| sub new { | |
| my ( $class, %method ) = @_; | |
| while ( my ( $method, $code_ref ) = each %method ) { | |
| next if ref $code_ref ne 'CODE'; | |
| my $slot = __PACKAGE__ . "::$method"; | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 目的: CGI::Application のテンプレートエンジンを Text::MicroTemplate::Extended で置き換える | |
| # 方法: MyApp::View::MT で HTML::Template との API の差を吸収する | |
| # 結果: できない -> https://gist.github.com/1993446 | |
| # 参考: | |
| # https://metacpan.org/module/CGI::Application#load_tmpl- | |
| # https://metacpan.org/module/Text::MicroTemplate::Extended | |
| # lib/MyApp.pm | |
| # html_tmpl_class で load_tmpl が呼ぶコンストラクタを変更する。 | |
| sub setup { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package MyApp::View::MT; | |
| use strict; | |
| use warnings; | |
| use parent 'Exporter'; | |
| use Text::MicroTemplate::Extended; | |
| our @EXPORT_OK = qw( render_mt ); | |
| sub import { | |
| my $caller = scalar caller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # while_each_last.pl | |
| use strict; | |
| use warnings; | |
| my %foo = ( foo => 'bar' ); | |
| while ( my ( $k, $v ) = each %foo ) { | |
| print "$k: $v\n"; | |
| last; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| my %method_of = ( | |
| get => \&Blosxom::Header::get_header, | |
| set => \&Blosxom::Header::set_header, | |
| exists => \&Blosxom::Header::exists_header, | |
| delete => \&Blosxom::Header::delete_header, | |
| push => \&Blosxom::Header::push_header, | |
| ); | |
| while ( my ( $method, $sub_ref ) = each %method_of ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| my %foo = ( | |
| start => 0, | |
| template => 0, | |
| entries => 0, | |
| filter => 1, | |
| skip => 1, | |
| interpolate => 1, | |
| head => 1, | |
| sort => 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package access_log; | |
| use strict; | |
| use warnings; | |
| use POSIX qw/strftime/; | |
| sub start { !$blosxom::static_entries } | |
| sub last { | |
| my $h = $ENV{REMOTE_ADDR}; | |
| my $l = '-'; |
OlderNewer