1、遍历给定目录,直接递归,不采用模块
(当年写的一个转换特定文件夹下所有文件编码的小程序)
use
IO::Dir;
use
Encode;
use
File::Copy;
use
strict;
sub
changeEncoding
{
die
"Wrong para number!"
if
not
defined
$_
[0] or not
defined
$_
[1];
my
(
$file
,
$base
) =
@_
;
my
$dir_fh
= IO::Dir->new(
$file
) or
die
"Can't open file: $file\n"
;
while
(
defined
(
my
$filename
=
$dir_fh
->
read
))
{
print
">> dealing with $filename.\n"
;
if
(
$filename
eq
'.'
||
$filename
eq
'..'
)
{
next