in reply to perl tk widget will not copy files

The first place I expect your code to fail is here: my $test_bak = "G:\\temp\\Hand"; Perl partially adheres to the syntax for unix file-systems, even on non-unix operating systems. So in this case I would expect the following to work instead: my $test_bak = "G:/temp/Hand";

Update: or rather the above assignment is the cause of this line to fail:  opendir (DIR, $test_bak) or warn $!

One world, one people

Replies are listed 'Best First'.
Re^2: perl tk widget will not copy files
by Corion (Patriarch) on Aug 11, 2015 at 09:41 UTC

    Why do you think that one would fail where the other would work?

    The Windows API takes both, slashes and backslashes as directory entry delimiters. Perl does not care either way. I just wonder why Windows should prefer one or the other when in my experience they are interchangeable.

      I am not sure of the design cause of this behaviour, although I have long been aware of it, but using ActiveState Perl v5.20.2, Perl could not find my home directory using backslashes or single backslashes, but changing to single forward slashes did make the opendir work on my laptop.

      Update: come to think of it, there are some advantages to Perl's uniform interface to file-systems. For example many algorithms that combine glob or opendir with recursive traversal will be portable between *nix and windows as a result.

      One world, one people

        On Windows 8.1 using Perl 5.20.2 running:

        use strict; use warnings; opendir my ($root), 'C:\Users\Default'; my @dirs = readdir $root; print "$_\n" for @dirs;

        Prints (in part):

        . .. AppData Application Data Cookies Desktop Documents Downloads Favorites Links Local Settings Music My Documents

        so it seems there is no "design cause" for the behaviour you see because it doesn't exist.

        perl -V reports in part:

        Summary of my perl5 (revision 5 version 20 subversion 2) configuration +: Platform: osname=MSWin32, osvers=6.3, archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.20.2.1 #1 Sat Feb 21 18:04:11 2015 +x64'
        Premature optimization is the root of all job security