liol's Journal http://use.perl.org/~liol/journal/ liol's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:45:40+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 liol's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~liol/journal/ Template::Toolkit::HTML::BBCode 0.01 released on CPAN http://use.perl.org/~liol/journal/23947?from=rss <p>This week I have uploaded <a href="http://backpan.cpan.org/authors/id/L/LI/LIOL/Template-Plugin-HTML-BBCode-0.01.tar.gz">TT2 wrapper around HTML::BBCode</a>.</p><p>Module provides filter which converts BBCode to HTML.</p><blockquote><div><p> <tt>[% USE HTML::BBCode %]<br>[% FILTER bbcode %]<br>&nbsp; [b]Bold[/b]<br>&nbsp; [i]Italic[/i]<br>&nbsp; etc<br>[% END %]</tt></p></div> </blockquote> liol 2005-03-31T09:00:12+00:00 journal new japh http://use.perl.org/~liol/journal/22934?from=rss <blockquote><div><p> <tt>#!/usr/bin/perl<br>$=-=$=;tie$;,'main';$_{$;,$;,$;,$;,$;,$;,$;,$;,$;,$;,$;,$;,$;}<nobr>=<wbr></nobr> $=;($_=<br>each%_)?print:_;sub TIESCALAR{bless[split'',"jtqq\x1C\x5chhl_[g\x14c".<br>"Wc\x5C\x0FVNOVO[\x09"],$_[<nobr>$<wbr></nobr> =--];}sub FETCH{chr ord($_[0]-&gt;[$=])+$=++}</tt></p></div> </blockquote> liol 2005-01-28T18:54:21+00:00 journal First japh http://use.perl.org/~liol/journal/22695?from=rss <blockquote><div><p> <tt>#!/usr/bin/perl<br>eval qq{#line $$ "just another perl hacker"\ndie};$@=~/j.+r/;print$&amp;;</tt></p></div> </blockquote> liol 2005-01-13T13:25:23+00:00 journal Beautiful perl http://use.perl.org/~liol/journal/22413?from=rss Enjoy!<blockquote><div><p> <tt>#!/usr/bin/perl<br> <br>@a = @b = ( "%s %s\n", 'a', 'b' );<br> <br>print sprintf( @a );<br>print sprintf( shift @a, @a );<br>printf( @b );<br>printf( shift @b, @b );</tt></p></div> </blockquote> liol 2004-12-22T06:07:47+00:00 journal Convert from/to UTF8 TT2 filter plugin (unreleased). http://use.perl.org/~liol/journal/22400?from=rss <p>This is not released on CPAN module. After discussion in Template Toolkit mailing list it was decided not to publish it. Neighthertheless I'm saving it here. In two words, this is a wrapper around Unicode::MapUTF8. It provides two filters <b>from_utf8</b> and <b>to_utf8</b>.</p><blockquote><div><p> <tt>#==================================================== -*-Perl-*-<br>#<br># MyOrg::Template::Plugin::Unicode::MapUTF8<br>#<br># DESCRIPTION<br>#&nbsp; &nbsp;Wrapper around Unicode::MapUTF8 module which converts<br>#&nbsp; &nbsp;text in different charsets into UTF8<br>#<br># AUTHOR<br>#&nbsp; &nbsp;Igor Lobanov&nbsp; &nbsp;&lt;*@*&gt;<br>#<br># COPYRIGHT<br>#&nbsp; &nbsp;Copyright (C) 2004 Igor Lobanov.&nbsp; All Rights Reserved.<br>#<br>#&nbsp; &nbsp;This module is free software; you can redistribute it and/or<br>#&nbsp; &nbsp;modify it under the same terms as Perl itself.<br>#<br>#===============================================================<br> <br> package MyOrg::Template::Plugin::Unicode::MapUTF8;<br> <br>use strict;<br>use vars qw( $VERSION );<br>use Template::Plugin;<br>use Template::Exception;<br>use base qw( Template::Plugin );<br>use Unicode::MapUTF8 qw( to_utf8 from_utf8 utf8_supported_charset );<br> <br>$VERSION = sprintf("%d.%02d", q$Revision: 0.01 $ =~<nobr> <wbr></nobr>/(\d+)\.(\d+)/);<br> <br># Use this charset in filters by default<br>my $DEFAULT_CHARSET = 'ISO-8859-1';<br># Type name of TT exception<br>my $EXCEPTION_TYPE = 'MapUTF8';<br> <br># Hash with filter subs for each requested charset<br>my $filter_set = {};<br> <br>sub new {<br>&nbsp; &nbsp; my ( $class, $context ) = @_;<br>&nbsp; &nbsp; $context-&gt;define_filter( 'to_utf8', [ \&amp;to_utf8_filter, 1 ] );<br>&nbsp; &nbsp; $context-&gt;define_filter( 'from_utf8', [ \&amp;from_utf8_filter, 1 ] );<br>&nbsp; &nbsp; bless {}, $class;<br>}<br> <br>sub to_utf8_filter {<br>&nbsp; &nbsp; my ( $context, $charset ) = @_;<br>&nbsp; &nbsp; $charset ||= $DEFAULT_CHARSET;<br>&nbsp; &nbsp; utf8_supported_charset( $charset )<br>&nbsp; &nbsp; &nbsp; &nbsp; or die Template::Exception-&gt;new(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $EXCEPTION_TYPE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "character set '$charset' is not supported" );<br>&nbsp; &nbsp; # Create filter sub for charset only once and reuse it later<br>&nbsp; &nbsp; $filter_set-&gt;{$charset}-&gt;{'utf8'} ||= sub {<br>&nbsp; &nbsp; &nbsp; &nbsp; my $text = shift;<br>&nbsp; &nbsp; &nbsp; &nbsp; to_utf8( -string =&gt; $text, -charset =&gt; $charset );<br>&nbsp; &nbsp; };<br>&nbsp; &nbsp; return $filter_set-&gt;{$charset}-&gt;{'utf8'};<br>}<br> <br>sub from_utf8_filter {<br>&nbsp; &nbsp; my ( $context, $charset ) = @_;<br>&nbsp; &nbsp; $charset ||= $DEFAULT_CHARSET;<br>&nbsp; &nbsp; utf8_supported_charset( $charset )<br>&nbsp; &nbsp; &nbsp; &nbsp; or die Template::Exception-&gt;new(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $EXCEPTION_TYPE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "character set '$charset' is not supported" );<br>&nbsp; &nbsp; $filter_set-&gt;{'utf8'}-&gt;{$charset} ||= sub {<br>&nbsp; &nbsp; &nbsp; &nbsp; my $text = shift;<br>&nbsp; &nbsp; &nbsp; &nbsp; from_utf8( -string =&gt; $text, -charset =&gt; $charset );<br>&nbsp; &nbsp; };<br>&nbsp; &nbsp; return $filter_set-&gt;{'utf8'}-&gt;{$charset};<br>}<br> <br>1;<br> <br>__END__<br> <br>=head1 NAME<br> <br>MyOrg::Template::Plugin::Unicode::MapUTF8 - Template Toolkit<br>plugin wrapper around Unicode::MapUTF8.<br> <br>=head1 SYNOPSIS<br> <br>code:<br> <br> use Template;<br><nobr> <wbr></nobr>...<br> my $template = new Template(<br>&nbsp; &nbsp; &nbsp;...<br>&nbsp; &nbsp; &nbsp;PLUGIN_BASE&nbsp; &nbsp; =&gt; 'MyOrg::Template::Plugin'<br>&nbsp; &nbsp; &nbsp;...<br> );<br> <br>template:<br> <br> [% USE Unicode::MapUTF8 %]<br> <br> [%# From cyrillic KOI8-R to UTF-8 #%]<br> [% FILTER from_utf8( 'koi8-r' ) %]<br><nobr> <wbr></nobr>...<br> here UTF8 text<br><nobr> <wbr></nobr>...<br> [% END %]<br> <br> [%# From ISO-8859-1 (by default) to UTF-8 #%]<br> [% FILTER to_utf8 %]<br><nobr> <wbr></nobr>...<br> here ISO-8859-1 text<br><nobr> <wbr></nobr>...<br> [% END %]<br> <br>=head1 DESCRIPTION<br> <br>This Template Toolkit plugin implements two filters for<br>conversions to and from arbitrary character sets and UTF8.<br>Plugin uses Benjamin Franz module L&lt;Unicode::MapUTF8&gt;.<br> <br>=head2 to_utf8<br> <br> [% FILTER to_utf8( charset ) %]<br><nobr> <wbr></nobr>...<br> here text in<br><nobr> <wbr></nobr>...<br> [% END %]<br> <br>Converts text inside block to UTF8 from the specified source<br>charset. Default B&lt;charset&gt; value is I&lt;ISO-8859-1&gt;.<br> <br>=head2 from_utf8<br> <br> [% FILTER from_utf8( charset ) %]<br><nobr> <wbr></nobr>...<br> here UTF8 text<br><nobr> <wbr></nobr>...<br> [% END %]<br> <br>Converts text inside block from UTF8 to the specified source<br>charset. Default B&lt;charset&gt; value is I&lt;ISO-8859-1&gt;.<br> <br>=head1 SEE ALSO<br> <br>L&lt;Template|Template&gt;, L&lt;Unicode::MapUTF8|Unicode::MapUTF8&gt;<br> <br>=head1 AUTHOR<br> <br>Igor Lobanov, E&lt;lt&gt;*@*E&lt;gt&gt;<br> <br>=head1 COPYRIGHT<br> <br>Copyright (C) 2004 Igor Lobanov. All Rights Reserved.<br> <br>This module is free software; you can redistribute it and/or<br>modify it under the same terms as Perl itself.<br> <br>=cut</tt></p></div> </blockquote> liol 2004-12-21T18:09:23+00:00 journal My first... http://use.perl.org/~liol/journal/22359?from=rss <p>This week I got my first PAUSE experience. CPAN inside is beautiful. I suspected this but now I know.</p><p>My first published module is very specific one - plugin to Template Toolkit which implements filter for cyrillic to translit conversion (Template::Plugin::Translit::RU).</p> liol 2004-12-18T18:42:49+00:00 journal