それ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.
とか言っておいて目的を勘違いしてたら俺恥ずかしい