The updates don't help any. The question I asked in my original post remains. How can you tell where a file name ends? What you ask is not possible, unless you impose extra restrictions. Let's say the file contains the line:

C:\Program Files\Application Name\bin\app.exe > C:\Program Files\Appli +cation Name\log\app.log do_it 2> C:\Program Files\Foo Bar\log\app.log

Should the above return:

C:\Progra~1\Applic~1\bin\app.exe > C:\Progra~1\Applic~1\log\applog~1 2 +> C:\Progra~1\FooBar~1\log\app.log

Probably not. You probably wanted:

C:\Progra~1\Applic~1\bin\app.exe > C:\Progra~1\Applic~1\log\app.log do +_it 2> C:\Progra~1\FooBar~1\log\app.log

ok, so you might say you'll never place arguments between redirects (although it would be a exception to what you said you allow). What if the file contained the line:

C:\Program Files\Application Name\bin\app.exe ola c:\file1 ole c:\file +2

Should the above return:
C:\Progra~1\Applic~1\bin\appexe~1 c:\file1o~1 c:\file2
or
C:\Progra~1\Applic~1\bin\app.exe ola c:\file1o~1 c:\file2
or
C:\Progra~1\Applic~1\bin\app.exe ola c:\file1 ole c:\file2
Probably not the first, but there's no way to know between the bottom two. It depends on what app.exe expects.

That's why I recommended you quote your paths:

sub quote { local $_=$_[0]; s/(["\\])/\\$1/g; qq{"$_"} } sub unquote { local $_=$_[0]; s/^"(.*)"$/$1/ or return $_; s/\\(.)/$1/ +g; $_ } while (<IN>) { @items = /("(?:[^"\\]|\\.)+"|[^"\s]+)/g; foreach (@items) { $_ = unquote($_); print(Win32::GetShortPathName($_) || quote($_), ' '); } print("\n"); }

But that's not all! What the file doesn't exist? It's impossible to get the short file name of a file that doesn't yet exist!


In reply to Re: Parsing a list or Win32 filenames by ikegami
in thread Parsing a list or Win32 filenames by astroboy

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.