| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> |
|---|
| 3 | <head profile="http://purl.org/net/ns/metaprof"> |
|---|
| 4 | <!-- Document Metadata --> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 6 | <meta http-equiv="Content-Language" content="ja" /> |
|---|
| 7 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
|---|
| 8 | <meta http-equiv="Content-Script-Type" content="text/javascript" /> |
|---|
| 9 | <meta http-equiv="imagetoolbar" content="no" /> |
|---|
| 10 | |
|---|
| 11 | <!-- Atom news feed --> |
|---|
| 12 | |
|---|
| 13 | <link rel="alternate" type="application/rss+xml" title="RSS feed" href="http://coderepos.org/share/log/websites/perl-users.jp?limit=100&mode=stop_on_copy&format=rss" /> |
|---|
| 14 | <link rel="stylesheet" type="text/css" href="/css/fixed.css" /> |
|---|
| 15 | <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" /> |
|---|
| 16 | <link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon" /> |
|---|
| 17 | |
|---|
| 18 | <title>Perl 5 今昔 - Perl-users.jp</title> |
|---|
| 19 | |
|---|
| 20 | <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> |
|---|
| 21 | <script type="text/javascript"> |
|---|
| 22 | _uacct = "UA-4463402-1"; |
|---|
| 23 | urchinTracker(); |
|---|
| 24 | </script> |
|---|
| 25 | <script src="/js/codepress/codepress.js" type="text/javascript"></script> |
|---|
| 26 | </head> |
|---|
| 27 | <body> |
|---|
| 28 | <div id="head-navigation"><a href="/">Perl-users.jp</a></div> |
|---|
| 29 | <!-- content start --> |
|---|
| 30 | <h1>Perl 5 今昔</h1> |
|---|
| 31 | |
|---|
| 32 | <p>前は王道だったあの書き方も最近ではこうかな、というもの集です。</p> |
|---|
| 33 | |
|---|
| 34 | <h2>一般編</h2> |
|---|
| 35 | |
|---|
| 36 | <p>oldtype としたものもたいていは動きますし、環境の都合や軽量だなどの理由で普通に使われたりもします。そのへん勘違いなきよう。</p> |
|---|
| 37 | |
|---|
| 38 | <h3>CPAN シェル起動</h3> |
|---|
| 39 | |
|---|
| 40 | <ul> |
|---|
| 41 | <li>oldtype: <code>perl -MCPAN -e shell</code></li> |
|---|
| 42 | <li>modern: <code>cpan</code></li> |
|---|
| 43 | </ul> |
|---|
| 44 | |
|---|
| 45 | <h3>OR マッパー</h3> |
|---|
| 46 | |
|---|
| 47 | <ul> |
|---|
| 48 | <li>oldtype: Class::DBI</li> |
|---|
| 49 | <li>modern: DBIx::Class, Data::ObjectDriver</li> |
|---|
| 50 | </ul> |
|---|
| 51 | |
|---|
| 52 | <h3>テンプレートエンジン</h3> |
|---|
| 53 | |
|---|
| 54 | <ul> |
|---|
| 55 | <li>oldtype: HTML::Template</li> |
|---|
| 56 | <li>modern: Template</li> |
|---|
| 57 | </ul> |
|---|
| 58 | |
|---|
| 59 | <h3>文字コード</h3> |
|---|
| 60 | |
|---|
| 61 | <ul> |
|---|
| 62 | <li>oldtype: Jcode</li> |
|---|
| 63 | <li>modern: Encode</li> |
|---|
| 64 | </ul> |
|---|
| 65 | |
|---|
| 66 | <h3>ファイル名</h3> |
|---|
| 67 | |
|---|
| 68 | <ul> |
|---|
| 69 | <li>oldtype: File::Spec, File::BaseDir</li> |
|---|
| 70 | <li>modern: Path::Class</li> |
|---|
| 71 | </ul> |
|---|
| 72 | |
|---|
| 73 | <h3>open</h3> |
|---|
| 74 | |
|---|
| 75 | <ul> |
|---|
| 76 | <li>oldtype: <code>open FH, "filename" or die $!;</code></li> |
|---|
| 77 | <li>modern: <code>open my $fh, '<', 'filename' or die $!;</code> または <code>file('filename')->open('r')</code> とか</li> |
|---|
| 78 | </ul> |
|---|
| 79 | |
|---|
| 80 | <h3>クラス雛形</h3> |
|---|
| 81 | |
|---|
| 82 | <ul> |
|---|
| 83 | <li>oldtype: Class:Accessor::* とか</li> |
|---|
| 84 | <li>modern: Moose</li> |
|---|
| 85 | </ul> |
|---|
| 86 | |
|---|
| 87 | <h3>Makefile.PL</h3> |
|---|
| 88 | |
|---|
| 89 | <ul> |
|---|
| 90 | <li>oldtype: ExtUtils::MakeMaker</li> |
|---|
| 91 | <li>modern: Module::Install</li> |
|---|
| 92 | </ul> |
|---|
| 93 | |
|---|
| 94 | <h3>インタラクティブシェル</h3> |
|---|
| 95 | |
|---|
| 96 | <ul> |
|---|
| 97 | <li>oldtype: <code>perl -de0</code></li> |
|---|
| 98 | <li>modern: <code>re.pl</code> (Devel::REPL)</li> |
|---|
| 99 | </ul> |
|---|
| 100 | |
|---|
| 101 | <h3>日付処理</h3> |
|---|
| 102 | |
|---|
| 103 | <ul> |
|---|
| 104 | <li>oldtype: <code>time()</code> や <code>localtime()</code> でがんばったり Date::Simple, Time::Local, Date::Calc とか</li> |
|---|
| 105 | <li>modern: DateTime</li> |
|---|
| 106 | </ul> |
|---|
| 107 | |
|---|
| 108 | <h3>メール送信</h3> |
|---|
| 109 | |
|---|
| 110 | <ul> |
|---|
| 111 | <li>oldtype: Net::SMTP を直</li> |
|---|
| 112 | <li>modern: Email::Send, MIME::Lite など</li> |
|---|
| 113 | </ul> |
|---|
| 114 | |
|---|
| 115 | <h3>Public な変数</h3> |
|---|
| 116 | |
|---|
| 117 | <ul> |
|---|
| 118 | <li>oldtype: <code>use vars qw($VERSION);</code></li> |
|---|
| 119 | <li>modern: <code>our $VERSION;</code></li> |
|---|
| 120 | </ul> |
|---|
| 121 | |
|---|
| 122 | <h3>偽なら代入</h3> |
|---|
| 123 | |
|---|
| 124 | <ul> |
|---|
| 125 | <li>oldtype: <code>||=</code></li> |
|---|
| 126 | <li>5.10: <code>//=</code></li> |
|---|
| 127 | </ul> |
|---|
| 128 | |
|---|
| 129 | <h3>継承</h3> |
|---|
| 130 | |
|---|
| 131 | <ul> |
|---|
| 132 | <li>oldtype: <code>use base</code></li> |
|---|
| 133 | <li>modern: <code>use parent</code> (とくに Catalyst 周辺)</li> |
|---|
| 134 | </ul> |
|---|
| 135 | |
|---|
| 136 | <h2>恐怖の Catalyst 編</h2> |
|---|
| 137 | |
|---|
| 138 | <p>oldtype のものはサポートされなくなっていくと思われます。</p> |
|---|
| 139 | |
|---|
| 140 | <h3>Root</h3> |
|---|
| 141 | |
|---|
| 142 | <ul> |
|---|
| 143 | <li>oldtype: App.pm に書く(もういないかな)</li> |
|---|
| 144 | <li>modern: App/Controller/Root.pm に <code>__PACKAGE__->config->{namespace} = '';</code> してそこに書く</li> |
|---|
| 145 | </ul> |
|---|
| 146 | |
|---|
| 147 | <h3>基本最終処理</h3> |
|---|
| 148 | |
|---|
| 149 | <ul> |
|---|
| 150 | <li>oldtype: Catalyst::Plugin::DefaultEnd</li> |
|---|
| 151 | <li>modern: Catalyst::Action::RenderView</li> |
|---|
| 152 | </ul> |
|---|
| 153 | |
|---|
| 154 | <h3>DBIx::Class モデル</h3> |
|---|
| 155 | |
|---|
| 156 | <ul> |
|---|
| 157 | <li>oldtype: Catalyst::Model::DBIC</li> |
|---|
| 158 | <li>modern: Catalyst::Model::DBIC::Schema</li> |
|---|
| 159 | </ul> |
|---|
| 160 | |
|---|
| 161 | <h3>認証</h3> |
|---|
| 162 | |
|---|
| 163 | <ul> |
|---|
| 164 | <li>oldtype: Catalyst::Plugin::Authentication::*</li> |
|---|
| 165 | <li>modern: Catalyst::Plugin::Authentication と Catalyst::Authentication::*</li> |
|---|
| 166 | </ul> |
|---|
| 167 | |
|---|
| 168 | <h3>キャッシュ</h3> |
|---|
| 169 | |
|---|
| 170 | <ul> |
|---|
| 171 | <li>oldtype: Catalyst::Plugin::Cache::*</li> |
|---|
| 172 | <li>modern: Catalyst::Plugin::Cache と好きな Cache::</li> |
|---|
| 173 | </ul> |
|---|
| 174 | |
|---|
| 175 | <h3>まあそれでも</h3> |
|---|
| 176 | |
|---|
| 177 | <ul> |
|---|
| 178 | <li>oldtype: CGI::Application</li> |
|---|
| 179 | <li>modern: Catalyst</li> |
|---|
| 180 | </ul> |
|---|
| 181 | |
|---|
| 182 | <hr /> |
|---|
| 183 | |
|---|
| 184 | <p>あまり好みに走らないように気をつけつつ追記・修正よろしく!</p> |
|---|
| 185 | |
|---|
| 186 | <!-- content end --> |
|---|
| 187 | </body> |
|---|
| 188 | </html> |
|---|