http://www.perlmonks.org?node_id=984561


in reply to Re^5: rename to UTF8 filename
in thread rename to UTF8 filename

Thanks Man! It works now, and inspires a lot! I found I have 2 problem here.

1. If I don't use Path::Class, Win32::Unicode::File cannot survive on it's own. It ends up with Undefined subroutine.... when I call moveW()( How do you know that?? ). And I found the errorW(), dieW() won't work at all. Not sure if I missed something when I download this module via ppm.

2. I forgot the BOM char in my text list. It ends up by messing the file name and so File not found. After adding read ( F, $_, 1 ), then start to read. It reads correctly and moveW works!

But then, would you point out where absolute() and basename() method import from? I can't find it in the perldoc where the modules you used.

Anyway, thank you very much!

Replies are listed 'Best First'.
Re^7: rename to UTF8 filename
by Anonymous Monk on Aug 13, 2012 at 10:53 UTC

    If I don't use Path::Class, Win32::Unicode::File cannot survive on it's own. It ends up with Undefined subroutine.... when I call moveW()( How do you know that?? ).

    What does that mean?

    $ perl -E " use Win32::Unicode::File; use Data::Dump; dd \@Win32::Unic +ode::File::EXPORT, \&moveW ; moveW()" ( [ "file_type", "file_size", "copyW", "moveW", "unlinkW", "touchW", "renameW", "statW", "utimeW", ], sub { ... }, ) Usage: moveW(from, to [, over]) at -e line 1.

    And I found the errorW(), dieW() won't work at all. Not sure if I missed something when I download this module via ppm.

    You sure?

    $ perl -E " use Win32::Unicode; use Data::Dump; errorW(); dd [ $@, er +rorW() ]; eval { moveW() }; dd [ $@, errorW()]; eval { moveW(qw{ . . + }) }; dd[$@, errorW()]; dieW 666;" ["", "The handle is invalid."] [ "Usage: moveW(from, to [, over]) at -e line 1.\n", "The handle is invalid.", ] ["", "The handle is invalid."] 666 at -e line 1.

    But then, would you point out where absolute() and basename() method import from? I can't find it in the perldoc where the modules you used.

    Path::Class gives you Path::Class::File and Path::Class::Dir objects

    $ perl -MPath::Class -E " say file(1) " 1 $ perl -MPath::Class -E " say ref file(1) " Path::Class::File $ perl -MPath::Class -MData::Dump -E " dd file(1) " bless({ dir => undef, file => 1, file_spec_class => undef }, "Path::Cl +ass::File") $ perl -MPath::Class -E " say file(1)->basename " 1 $