それgrepでもできるよ

http://d.hatena.ne.jp/kiyo_hiko/20090603/1244038719

Perlで、こういう書き方は何とかならんものか?

if ($x == 1 or $x == 2 or $x == 3) {

何かの処理;

}

use strict;
use warnings;

my @match = qw/1 2 3/;
for my $x (qw/-1 0 1 2 3 4/) {
    if (grep /$x/, @match) {
        warn " hit: $x";
    }
    else {
        warn "not : $x";
    }
}
% perl match.pl
not : -1 at match.pl line 10.
not : 0 at match.pl line 10.
 hit: 1 at match.pl line 7.
 hit: 2 at match.pl line 7.
 hit: 3 at match.pl line 7.
not : 4 at match.pl line 10.


とか言っておいて目的を勘違いしてたら俺恥ずかしい

追記

コメントで指摘されたように、これだと例えば 1 でgrepして 11 が誤爆したりするので
eq やら == で比較した方がよろしげです。俺はずい。

セッション切れる

sledge-bbsで自宅サーバでセッション吐いた後画面遷移しただけでセッション切れるーって言ってる件。
centos5なのが悪いんかと思って他環境のcentos5で試したら正常動作セッション保持。
つまり俺のマシンが変なの確定。
ゑー。
いやちょっと待ってcatalystだとちゃんとセッション保持するから。わからん。