#!/usr/local/bin/perl

use strict;
# use encoding "cp932"; # このスクリプトファイルで使われている文字コードをcp932とみなす。…@
# use open ":encoding(cp932)"; # cp932をファイル入出力するために必要。(@がリセットされてしまう)
# use open ":std"; # @のリセットを戻しつつ、標準エラー出力をcp932化する。
# ##binmode STDERR, ":encoding(cp932)"; # 標準エラー出力をcp932化する。
# 標準出力の改行がCRLFではなくLFのみになってしまう
#  ↓ ↓ ↓
# これでOK
use encoding "cp932", STDIN => undef, STDOUT => undef;
use open qw(:encoding(cp932) :std);

use Encode;
sub toCp932 { encode("cp932", shift); } 

print 'あいうえお表@〜', "\n", "A";
print STDOUT 'あいうえお表A〜', "\n", "A";
print STDERR 'あいうえお表B〜', "\n";


#my $outFile = "abc.txt";
my $outFile = "あいうえお表C〜.txt";
#open(OUT, ">$outFile") or die "!! Can't open $outFile\n";
open(OUT, ">", toCp932($outFile)) or die "!! Can't open $outFile\n";
print OUT 'あいうえお表D〜', "\n", "A";
#print OUT toCp932('あいうえお表D〜'), "\n";
#print OUT $inTxt;
close OUT;

#my $inFile = "def.txt";
my $inFile = "あいうえお表E〜.txt";
open(IN, "<", toCp932($inFile)) or die "!! Can't open $inFile\n";
print <IN>;
close IN;

mkdir(toCp932("あいうえお表G〜"), 0777);

my $miso = "ミソ";
#my $miso = "あいうえお表H〜";
$miso = toCp932($miso);
system("echo ".$miso); # 未解決（systemはダメ？）

#<STDIN>

# 
# Perl 5.8.x Unicode関連
# http://www.rwds.net/kuroita/program/Perl_unicode.html
# 
# Perlのページ
# http://homepage1.nifty.com/nomenclator/perl/index.htm
# 
# ハードなソフトの話
# http://hardsoft.at.webry.info/200604/article_2.html
# http://hardsoft.at.webry.info/200606/article_1.html
# http://hardsoft.at.webry.info/200803/article_6.html
# 
# Perl 5.8 Documentation - perljp - 日本語 Perl ガイド
# http://perl.active-venture.com/pod/perljp.html
# 
# Perl-5.8 MEMO
# http://www.namazu.org/~tsuchiya/perl/perl-5.8.html#japanese
# 
# Perlによる日本語コード変換のメモ
# http://hikoboshi.org/perl/doc/encode_old.html
# http://hikoboshi.org/perl/utf8.html
# 
# Perl の多言語処理 - Perl ヒント集 (ja)
# http://www.fl.reitaku-u.ac.jp/~schiba/perl/perlEncoding.html
# http://www.fl.reitaku-u.ac.jp/~schiba/perl.html#textProcessing
# 
# Windows環境 ActivePerl で日本語を使用する
# http://www.geocities.jp/htmdoc/activeperl-UTF8.html
# 
# ActivePerl + 日本語 ふたたび
# http://miau.s9.xrea.com/blog/index.php?itemid=120
# 
# WindowsでPerl 5.8/5.10を使うモンじゃない
# http://www.aritia.org/hizumi/perl/perlwin.html
# 
# Windows環境のActivePerlのencodingモジュールと改行の関係
# http://d.hatena.ne.jp/hiront_at_nagoya/20090920/1253445859
# 
# ActivePerl v5.10 + Windows CP932 (Shift JIS) 日本語ファイル名の扱い 
# http://u.hoso.net/2009/07/activeperl-v510-windwos-cp932-shift-jis.html
# 
# dyno2316: Windows版ActivePerl5.8.Xで日本語処理
# http://dyno2316.blogspot.com/2009/07/windowsactiveperl58x.html
# 
# Perl - ちばれ's Wiki
# http://www.tsibale.com/wiki/?Perl
# 
# Windows環境のActivePerlのencodingモジュールと改行の関係 - とりあえずメモメモ。
# http://d.hatena.ne.jp/hiront_at_nagoya/20090920/1253445859
# 

