こんなことを書いていたら Perl で JS の arguments.callee 的なことしようと思ってハマった - IT戦記 さっそく教えて貰えた>< http://d.hatena.ne.jp/tokuhirom/20080501/1209625789 ありがとうございます! さっそく使ってみた! 以下のコードを # test.pl use strict; use warnings; use Devel::Caller qw(caller_cv); sub { my $c = shift; print "$c \n"; caller_cv(0)->($c) if ($c --); }->(10); 実行! $ perl test.pl 10 9 8 7 6 5 4 3 2 1 0 $ おおおおおお。キタコレ!かなりシンプル! これで無名関数の再帰ができる>< id:tokuhirom
Stevan Little stevan@iinteractive.com Vienna, Austria August 29th, 2007
Perlでutf-8って、何かと面倒くさいのね。前に使ってたのは5年ぐらい前に共用サーバでcgi書いてたぐらいだから全く把握してなかった。 まず判断が付かないのが、use utf8;した方がいいのかどうか。全部utf-8な環境では最初にuse utf8;しておくのが吉とdankogaiも言ってる。確かにマルチバイト文字列の長さを見たり、正規表現を通すには指定しておいた方がよさげ。でも、周りのライブラリがついてこなかったりして困る。 DBIで直接DBを叩いている古いスクリプトを移行したら、DBから取ってきたデータが文字化ける。DBIx::Classで取ってくるようにして、utf8_columns指定したら解決した。ただ、この状態でDB内のデータがどうなっているかとか、他のスクリプトとの連携がどうなるかは確認できていないので要調査。 DBからデータを拾ってくるのはよしとして、Template:
検索結果キーワードをハイライトするPerlモジュール 2006-02-11-1 [Programming] HTML::ColorKeywords <http://ta2o.net/tools/pm/src/HTML-ColorKeywords-0.1.tar.gz> <http://ta2o.net/tools/pm/src/> (←最新版を調べるときはこっち) キーワード(複数)とマッチする箇所を span + background-color で ハイライトするPerlモジュールを作ってみました。 そもそも、Yasazon や AsamasiBookSearch で使ってたやつなのです。 このたび練習がてらPerl Module化[2006-02-03-3]してみました。 ↓こんな感じでハイライト。 なお、色はYahoo!のWeb検索結果のキーワードの色(10色)に準拠。 まあ、車輪
2008-10-21 追記 いまだに(ありがたいことですが)検索で飛んできたりブクマされたりというのがちょいちょいあるので,最新動向を書いておきます。 id:tokuhirom さんが Lingua::JA::Regular::Unicode という Pure Perl Module をリリースなさいました(→ http://d.hatena.ne.jp/tokuhirom/20081018/1224300947)。 あなたが作っているアプリで文字列まわりを Unicode::Japanese インスタンスですべて持ちたいわけでなければ(そして,たいていのばあい,持つ必要はないのですが),この Lingua::JA::Regular::Unicode を使うのがベターです。依存性もなく,とても軽量ですので。 2008-10-21 追記おわり ウェブアプリを作っていると,ユーザが入力した半角
2007年12月08日20:30 カテゴリLightweight Languages perl - Lingua::JA::Kana released! かなとローマ字をシンプルに相互変換するモジュールです。 dankogai's p5-lingua-ja-kana at master - GitHub @CPAN (as soon as PAUSED) 車輪の再発明ではあるのですが、どの車輪もちょっと不適当だったので。 私が欲しかったのは、お気軽にカナとローマ字の相互変換をするものだったのですが、Lingua::JA::Romajiは対象文字列がEUC-JPでないと駄目で古すぎで、KawaさんのLingua::JA::Romanize::*はちょっとヘビーウェイトすぎというわけで作りました。 ちょっと test suite が少なすぎるので、テスト募集中です。 Dan the Perl
そもそも論ですけど Similar to C but instantiates plugins as soon as they're found, useful for code generators like C. ってあるように、Module::Pluggableと同じインターフェースな訳じゃなくて似てるモジュールです。 似てる 速い すぐインスタンス化する ってのが特徴ですね。 同様にimport経由でpluginの読み込みを行います。 Module::Pluggable::Fast import() sub import { my ( $class, %args ) = @_; my $caller = caller; no strict 'refs'; *{ "$caller\::" . ( $args{name} || 'plugins' ) } = sub { my $sel
名前 autobox::Core - Perl 組み込み関数をプリミティブ型のメソッドに 概要 use autobox; use autobox::Core; "Hello, World\n"->uc()->print(); 説明 数値, 文字列, 配列, ハッシュ, そしてコードリファレンスを操作する perl組み込み関数をラップするメソッド. 厄介なデリファレンス構文や 括弧の衝突を避けるために組み込み関数をメソッドして利用するのに便利です. autobox はオブジェクトリファレンスではないスカラーに対して メソッド呼び出しを提供します. 数値, 文字列, 数値を含んだスカラー, 文字列を含んだスカラー, 配列リファレンス, ハッシュリファレンス, そしてコードリファレンス全てオブジェクトとして動作します. autobox は perl にこの機能を提供しますがそれ自身では 呼
Web::Scraper はいたれりつくせりの仕掛けが仕込んであって、便利ですね。私が、割と良く使っている機能は以下 2 つです。 process の第一引数に、CSS セレクタだけでなく、XPath も指定できます。ただし、XPath を指定するときは先頭を必ずスラッシュ(/)で始めなければいけません。 process の第二引数以降の、値をどこから取得するかを指定する部分に、コード・リファレンスを置くこともできます。これを使うと、DOM ツリー中の値を加工して抽出することができます。 具体例として、デイリーポータルZのアーカイブ一覧の中からべつやくれいさんのエントリを抽出してみることにします。まず、アーカイブ・ページのエントリ部分を取り出してやると、こうなっています。 <TD width="580" valign="top" class="tx12px"> <P> <B><FONT c
スタンドアロンWebサーバ書くのにPOE::Component::Server::HTTPはかなりお手軽ですね。エラー処理とかいろいろはしょると以下のコードで、Webサーバが走ります。 use strict; use warnings; use POE qw( Component::Server::HTTP Sugar::Args ); my $httpd_aliases = POE::Component::Server::HTTP->new( Port => 8080, ContentHandler => { '/' => \&httpd_index, } ); sub httpd_index { my ($request, $response) = @_; $response->code(RC_OK); $response->content('Hello, POE!'); return
Data::Pageとページナビゲーション 検索などで多くのページがヒットしたときの、ページナビゲーション << 3 4 5 6 *7 8 9 10 11 12 >> の部分をうまく扱って、100ページ分とかあっても、前後のページのみ表示するモジュールを探していたんだけど、良いのが見つからない。 Data::Pagesetというのがあるんだけど、思ったのと違う。 トータルエントリーが30、1ページ5つのエントリーとして、ナビゲーションのリンクは4つとした場合に、Data::Pagesetでは、 ページ1の場合 *1, 2, 3, 4 ページ2の場合 1, *2, 3, 4 ページ3の場合 1, 2, *3, 4 ページ4の場合 1, 2, 3, *4 ページ5の場合 *5, 6 ページ6の場合 5, *6 となってしまいます。*がついているところは現在のページを表してます。 希望としては、
Windows 10 の入ったディスクのバックアップが clonezilla で外形的にできることがわかった Posted on Jun 27, 2020 Windows10 が載ってるディスクに破壊的な変更加える前にバックアップしたくて、SystemRescueCd で clonezilla 使ってディスクまるごとイメージ化した(内部的には partimage が使われてる?)。 でこれ、レストアしたら起動する状態まで持っていけるんかな? すんごく不安だ。。。 — woremacx (@woremacx) June 15, 2020 systemrescuecd に同梱されている clonezilla を使ってまるまる取った Windows 10 のバックアップが戻せるか不安で仕方なかったので、VirtualBox に戻せるか試した。 そもそもなぜ clonezilla を試したかったの
Perl の Storable モジュールのメモ 2006-05-09-2 [Programming] Perl の Storable モジュールでちょっとだけ複雑なデータを扱うときの自分用 SYNOPSIS。参考「続・初めての Perl」[2006-05-09-1]。 #!/usr/bin/perl use strict; use warnings; use Storable qw(nstore retrieve); my ($first, $second); $first->{uhyo} = { 'abc' => 123, 'xyz' => 9, }; $first->{hogera} = { 'AAAAA' => [1, 2, 3], 'ABCDEF' => [60,1], 'W002' => [9, 1, 2], }; test_print($first); nstore [ $f
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く