Hi!

I want a running perl script to process every dropped file dragged from Explorer, but I don't know how drag&drop work in Windows.

I wrote this simple script as test.pl to get an idea of what is happening when it is running in its own window after a double click:

#!perl use strict; use warnings; while (<>) { print $_; }

The result is that if I drag one file to the Strawberry perl window, I can see the file's full path, but I have to press the Enter key with the focus in that window to make the script get the file, i.e. to print back the path. This means that only the file path name is sent to the script, without a newline.

What if I drag multiple files to the perl window? Only one filename is received, and no newline...

Is there a module or exteral tool that I could use in order to receive dropped files to the running window? Is adding the handler to the registry in order to run the script by dropping files to its icon the only way?

Thanks!!!

Edit: I first tried a oneliner in CMD with the same result.

perl -pe ""

In reply to How to process dropped files by vitoco

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.