camel

��Ũ!

�黻�� | �� overload ���� TT �Υե��륿�ߤ����ʵ�ˡ��������� - ������ �ϤƤʻ�Ź
<?= $value | replace('x','y') | uri ?>
��������˽񤱤�����Ũ�Ǥ���͡��Ȥ������ȤǤ���ʤΤ�񤤤Ƥߤ���

�Ǥ⡢���ΤޤޤǤϤ���äȻȤ��Ť餤�Τǡ������դ�ľ����Sub::Pipe�Ȥ���CodeRepos�ˤ�p���Ƥ����ޤ�����

�������ϡ��ʲ����̤ꡣ

  • ��������Filter�Ȥ����⥸�塼��̾�Ϥޤ������������ե��륿���ϤȤ��֤롣
  • ľ��coderef��bless����ΤϤ���ä���������­��ʤ���

�ʾ��ľ�����Τ����ʲ��Ǥ�����������ʬ��AS IS�ǡ�

package Sub::Pipe;
use warnings;
use strict;
our $VERSION = '0.01';
use base 'Exporter';
our @EXPORT = qw/joint/;

use overload '|' => sub { $_[0]->( $_[1] ) };

sub joint(&) { bless $_[0], __PACKAGE__ };

if ( $0 eq __FILE__ ) {
    local $\ = "\n";
    my $uri = joint { use URI::Escape; uri_escape_utf8(shift) };
    my $html = joint {
        my $str = shift;
        $str =~ s{([&<>"])}{
            '&' . { qw/& amp  < lt > gt " quot/ }->{$1} . ';' ;
        }msgex;
        $str;
    };
    my $html_line_break = joint {
        local $_ = $_[0];
        s{\r*\n}{<br/>}g;
        $_;
    };
    my $replace = sub {
        my ( $regexp, $replace ) = @_;
        joint {
            my $str = shift;
            $str =~ s{$regexp}{$replace}g;
            $str;
        }
    };
    print "dankogai" | joint { uc shift };
    print "<pre>" | $html;
    print "Perl & Me" | $uri;
    print "PHP" | $replace->( 'HP', 'erl' );
    print "Rock\nRoll" | $html_line_break | $uri;
}

1; # End of Sub::Pipe                                                           

�ޤ�CPAN�ˤϤ�p���Ƥޤ��󡣤��Τޤ� id:sfujiwara ����� CodeRepos ��ͳ�δ�£�Ȥ������Ȥǡ����ɤ��ʤ�CPAN�ؤΤ�p��䤬��äƤ����ޤ�����

Dan the Perl Monger