This question is, I suspect, really about Windows 8.1, but I think I'm more likely to get a sensible response here!

Until a few months ago I was still running XP on my desktop machine. One of the perl scripts copied picture files from a camera's SD card to the file system using the date as a directory name. This worked fine, because the multimedia stuff was all on a SATA drive, so the pathname could be hard-coded

When the desktop crashed terminally, and everything had to transferred to the laptop (which runs W8.1), I had to rewrite the code, as the multimedia stuff is now on an external USB drive, and the drive letter won't necessarily stay the same over time. I eventually came up with this code to find the multimedia drive:

sub FindPicDrive { foreach (Win32::DriveInfo::DrivesInUse()) { my $tmp = $_ . ":\\Documents and Settings\\Alan\\My Documents\ +\My Pictures"; # Must also find several directories matching the pattern m[^\ +d{4}_\d{2}_\d{2}$] print "Checking $tmp\n"; if (-d $tmp) { print "Opening $tmp\n"; eval { opendir DH, $tmp or die "This shouldn't happen: $!\n"; }; if ($@) { print "Open fail $! -- shouldn't happen -- ignoring... +\n"; next; } my $count; my @picdirs = grep /^\d{4}_\d{2}_\d{2}$/, readdir DH; #print join(', ',@picdirs), "\n"; closedir DH; if (@picdirs > 5) { print $tmp, ' ', scalar(@picdirs), "\n"; return $tmp; } } } }

which generates this output:

Checking C:\Documents and Settings\Alan\My Documents\My Pictures Opening C:\Documents and Settings\Alan\My Documents\My Pictures Open fail Invalid argument -- shouldn't happen -- ignoring... Checking D:\Documents and Settings\Alan\My Documents\My Pictures Checking E:\Documents and Settings\Alan\My Documents\My Pictures Checking F:\Documents and Settings\Alan\My Documents\My Pictures Checking G:\Documents and Settings\Alan\My Documents\My Pictures Checking H:\Documents and Settings\Alan\My Documents\My Pictures Checking I:\Documents and Settings\Alan\My Documents\My Pictures Opening I:\Documents and Settings\Alan\My Documents\My Pictures I:\Documents and Settings\Alan\My Documents\My Pictures 480 Pic stuff at I:\Documents and Settings\Alan\My Documents\My Pictures

Further investigation showed that, under W8.1, the path 'C:\Documents and Settings\Alan\My Documents\My Pictures' actually maps to 'c:\Users\Alan\Pictures', because several of the path elements are links (.lnk files)

The strange thing is that the -d test seems to work correctly on the former path, but then the same string fails when used as an argument to the opendir function

Shurely shome mishtake?

By the way, output from perl -V is:

Summary of my perl5 (revision 5 version 18 subversion 1) configuration +: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread-64in +t uname='Win32 strawberry-perl 5.18.1.1 #1 Tue Aug 13 19:20:13 2013 +i386' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPER +L_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fno-strict-alias +ing -mms-bitfields', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.7.3', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='lo +ng long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\straw +berry\c\lib"' libpth=C:\strawberry\c\lib C:\strawberry\c\i686-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 +-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -l +mpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdl +g32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_3 +2 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl518.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE +" -L"C:\strawberry\c\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PERL_SAWAM +PERSAND USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Aug 13 2013 19:29:16 @INC: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .

In reply to links in pathnames under Windows 8 by meistersinger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.