2010-01-29から1日間の記事一覧

Ruby で MySQL に接続できるようにする

いつになったら、Ruby 1.9 系で安定して MySQL に接続できるようになるのだろうか。 MySQL は XAMMP でインストールされるものを利用。 C:\>ruby -v ruby 1.8.7 (2009-12-24 patchlevel 248) [i386-mswin32] C:\>gem install dbi Successfully installed dep…

Ruby で配列から特定の要素のみを抽出する場合

#!/usr/bin/env ruby # -*- coding: utf-8 -*- aiueo = ['あ', 'い', 'う', 'え', 'お'] auo = aiueo.values_at(0, 2, 4) auo.each do |word| puts word end 実行結果は あ う お となる。 応用編 カンマ区切りで二重引用符のフィールドセパレーターの CSV …

Perl で配列から特定の要素のみを抽出する

#!/usr/bin/env perl my @numbers = (0, 1, 2, 3, 4, 5); my ($zero, $one, $two, $three, $four, $five) = @numbers; printf("%d, %d, %d, %d, %d, %d\n", $zero, $one, $two, $three, $four, $five); my ($this_is_one, $this_is_three, $this_is_five) = …