Yes, that works, but when you start adding the full path which also includes spaces, it fails.

The issue is with getting the quoting and escaping set correctly for the shell.

c:\test>dir "C:\Music\Ray LaMontagne" Volume in drive C has no label. Volume Serial Number is 4CD3-F30A Directory of C:\Music\Ray LaMontagne 07/30/2015 02:31 PM <DIR> . 07/30/2015 02:31 PM <DIR> .. 07/30/2015 02:31 PM 0 2010 - God Willin' & The Creek +Don't Rise.txt 1 File(s) 0 bytes 2 Dir(s) 938,700,210,176 bytes free c:\test>type Perl-1.pl #!/usr/bin/perl use 5.010; use strict; use warnings; use Data::Dumper; # I created this full path for the test my $fn = q(C:\Music\Ray LaMontagne\2010 - God Willin' & The Creek Don' +t Rise); print $fn, $/; #my $fn = "this 'is' a text file.txt"; my @s = stat $fn; print Dumper \@s; c:\test>Perl-1.pl C:\Music\Ray LaMontagne\2010 - God Willin' & The Creek Don't Rise $VAR1 = [];

I've delt with this issue before and always need to run a bunch of tests to get the quoting/escaping correct.


In reply to Re^3: stat on file name containing single quotes by fishmonger
in thread stat on file name containing single quotes by perlpipe

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.