my @input_numbers = (1, 2, 4, 8, 16, 32, 64);
my @result = map {
my @digits = split //, $_;
if ($digits[-1] == 4) {
join ”,@digits;
} else {
( );
}
} @input_numbers;
print “@result”;
OUTPUT: 4 64
my @input_numbers = (1, 2, 4, 8, 16, 32, 64);
my @result = map {
my @digits = split //, $_;
if ($digits[-1] == 4) {
join ”,@digits;
} else {
( );
}
} @input_numbers;
print “@result”;
OUTPUT: 4 64
Parrot[http://www.parrot.org/]
Parrot is a virtual machine designed to efficiently compile and execute bytecode for dynamic languages. Parrot currently hosts a variety of language implementations in various stages of completion, including Tcl, Javascript, Ruby, Lua, Scheme, PHP, Python, Perl 6, APL, and a .NET bytecode translator. Parrot is not about parrots, though we are rather fond of them for obvious reasons.
If you’re a computer programmer or a programmer wannabe then here’s a great list of free computer programming ebooks for learning programming languages such as Python, Perl, C++ and many more. These books are absolutely free and 100% legal to download and use. Click here to get Free Computer Programming Books http://dlvr.it/1f8HHb
コーディング・スタイル・チェッカー
日付と時刻関連のPerlモジュール
Perlで実装されたbash(らしい
Hindi namin nakuha yung shirt.
Can’t Talk.
Coding.
Bye.
TAKESAKO @ Yet another Cybozu Labs: 記号でPolyglotプログラミング♪(RejectKaigi2009)
さくらインターネットでCPANを利用する (おぼへがき)
配列の差集合などの取り方メモ。
http://dev-man.seesaa.net/article/117885645.html から引用。
——————
Perlは問題点の多い言語と言われますが、やはり実用性は本当に高いな、と思う今日このごろ。大きなプログラムを書いても遅くならないし。
さて、2つの配列の積集合(共通する要素)、和集合(いずれか一方または両方に含まれる要素)、差集合(一方にのみ含まれる要素)を求めるには、List::Compare が便利みたいなので試してみた。
#!/usr/bin/perl
use List::Compare;
# 比較する二つの配列
my @list1 = ('a', 'b', 'c');
my @list2 = ('b', 'c', 'd');
my $lc = List::Compare->new(\@list1, \@list2);
# 積集合 (@list1, @list2 両方の配列に含まれる要素)
my @intersection = $lc->get_intersection;
print "@intersection \n";
# prints b c
# 和集合(@list1, @list2 のすべての要素から重複を取り除いたもの)
my @union = $lc->get_union;
print "@union \n";
# prints a b c d
# 差集合 (@list1にのみ含まれる要素)
my @list1only = $lc->get_Lonly;
print "@list1only \n";
# prints a
# 差集合 (@list2にのみ含まれる要素)
my @list2only = $lc->get_Ronly;
print "@list2only \n";
# prints d
より詳しくは: http://search.cpan.org/dist/List-Compare/lib/List/Compare.pm
差集合だけで良い場合は Array::Diffでも良いみたい。