【これだけ覚えりゃなんとか使えるPerlメモ7】各種変換処理

文字列を小文字化

$str =~ tr/[A-Z]/[a-z]/;

文字列を大文字化

$str =~ tr/[a-z]/[A-Z]/;

10進->8進変換

$out = sprintf("%o", $in);

8進->10進変換

$out = oct($in);

10進->16進変換

$out = sprintf("%x", $in);

16進->10進変換

$out = hex($in);

日付の書式設定

use POSIX 'strftime';

my $now = strftime "%Y/%m/%d %H:%M:%S", localtime;
print $now, "\n";

または

use Date::Simple;

my $date = Date::Simple->new();
print $date->format('%Y/%m/%d'), "\n";