perl 指定したファイルを指定した名前に変更する

#指定したファイルを指定した名前に変更するスクリプト
#ファイル名の変更
#rename.pl

print "変更前のファイル名>";
$from_file = <STDIN>;
print "変更後のファイル名>";
$to_file = <STDIN>;

chomp($from_file, $to_file);

#名前の変更
rename($from_file, $to_file) || die "$from_file から $to_file に名前変更出来ません。:$!\n";

#実行結果
# 変更前のファイル名>test.txt
# 変更後のファイル名>testtesttesttxt

初めてのPerl 第6版

初めてのPerl 第6版