in reply to Re: Changing path to home directory
in thread Changing path to home directory

Close!

#!/usr/bin/perl use 5.018; use strict; use warnings; # 1118814 use Cwd; use File::HomeDir(); my $cwd = getcwd(); say "At Ln 12: \$cwd: $cwd"; my $HOME = File::HomeDir->my_home; chdir $HOME or die "Couldn't chdir $HOME: $!"; say "At Ln 18; \$HOME: $HOME"; $cwd = getcwd(); say "At Ln 21, \$cwd: $cwd"; =head Execution: C:\>D:\PMonks\1118814.pl At Ln 12: $cwd: C:/ At Ln 18; $HOME: C:\Users\ww At Ln 21, $cwd: C:/Users/ww =cut

Replies are listed 'Best First'.
Re^3: Changing path to home directory (M$ warning)
by Discipulus (Canon) on Mar 05, 2015 at 09:59 UTC
    Only a remark: on windows be very carefull mixing the Perl's idea of cwd with the OS's one.
    Given you have a drive y: can you predicdt the output of the following command? ;=)
    c:\path> y: & cd c:\ & dir c: & cd c:\Windows & dir c: & dir \
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re^3: Changing path to home directory
by Anonymous Monk on Mar 05, 2015 at 02:27 UTC

    Good to know it works, thanks for testing. In regards to the "Close!" I don't see the significant difference? (AFAIK backslashes are "more correct" on Windows since forward slashes usually but don't always work?)

      The slashes and backslashes in the =head Execution: section are artifacts of the Perl/Win32 interaction; they were NOT coded into the script.

      But s/Close!/Expanding upon the above:/ would have been better content for para 1.