実用的なプログラムを組んでみました。
Windows用の文字コードや改行コードをLinux用に自動変換します。
コマンドで出来るじゃんとは言わないでください^^;
コマンドの知識が無くてもと言うことで作りました。
あと、system関数の動きも気になりましたのでw
#!/usr/bin/perl
##########################################
#ソフト名 Changing line
#ファイル名 euc.pl
#作成者 orbit
#作成者HP https://www.orsx.net/
#
#ファイルの改行コードや文字コードを
#文字コードEUC改行コードLFへ変換します。
#########################################
$L='=' x 60;
$l='-' x 60;
#指示を表示
print"$Ln";
print"Please input the address until filing in then";
print"inclusion of the line feed code for Windows.n";
print"$Lnn";
#指示を表示
print"Is the directory moved?n";
$d=<stdin>;
chomp $d;
#ディレクトリ名の最後の/を確認
if($d eq ""){
$u = "./";
$d = "$u$d";
}elsif($d !~ //$/){
$s = "/";
$d = "$d$s";
}
#ファイルリストを表示
print"$ln";
print"<directory list>n";
print"$ln";
system ("ls $d");
print"$ln";
#ユーザーの入力の待機
print"Enter #t";
$d1=<stdin>;
chomp $d1;
#ファイル存在の確認
unless(-f "$d$d1") {
print "There is no file!n";
exit;
}
#指示を表示
print"n$Ln";
print"Please input the directory at the file at then";
print"output destination and the output destinations.n";
print"$Ln";
#ユーザーの入力の待機
print"Enter #t";
$d2=<stdin>;
chomp $d2;
if($d1 eq "" || $d2 eq ""){
print "It was not possible to make a file.n";
exit;
}
#ファイルのコードを変更
system ("nkf -e -Lu $d$d1 > $d$d2");
#ファイルリストを表示
print"n$ln";
print"<directory list>n";
print"$ln";
system ("ls $d");
print"$ln";
print"The '$d2' file ist";
system ("nkf --guess $d$d2");
0 Comments.