# Drag and drop

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on

I would like to be able to drag and drop files onto a .pl file  in the same
way I can drop files onto a .bat file. I made a .bat which can do this but
if I try to do the same thing with a .pl file I find the .pl file isn't able
to accept files for drag and drop operations, the cursor changes to the "not
allowed operation" symbol when the file being dropped is over the .pl file.
What do I have to do to the .pl file to make it work like the .bat file?

Example of .bat file onto which a file can be dropped:

@echo off
:plot_loop
print.pl p=1 %1
shift
if not "%1"=="" goto plot_loop

Example of .pl file that I would like to do the same as the .bat file:

use strict;
use warnings;

foreach (@ARGV) {
system("print.pl p=1 $_"); } regards Peter ## Re: Drag and drop * Tino wrote: > > I would like to be able to drag and drop files onto a .pl file in the same > way I can drop files onto a .bat file. I made a .bat which can do this but > if I try to do the same thing with a .pl file I find the .pl file isn't able > to accept files for drag and drop operations, the cursor changes to the "not > allowed operation" symbol when the file being dropped is over the .pl file. > What do I have to do to the .pl file to make it work like the .bat file? If you've a version of ActiveState's Perl installed have a look into its bin-directory. You will find a small tool named "pl2bat.bat" which wrap your perl code into a batch file. Otherwise you can add a new key to your windows registry to imitate the behavior of batch files. Then you can drag and drop your files directly to you perl script. Just create the key HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\ with default value set to "". Don't ask something about this CLSID, for me this works on a german winxp machine. Perhaps you wanna compare this with your own system settings. I've copied this value from HKEY_CLASSES_ROOT\batfile\shellex\DropHandler\ regards, fabian ## Re: Drag and drop >* Tino wrote: >> >> I would like to be able to drag and drop files onto a .pl file in the >> same >> way I can drop files onto a .bat file. I made a .bat which can do this >> but >> if I try to do the same thing with a .pl file I find the .pl file isn't >> able >> to accept files for drag and drop operations, the cursor changes to the >> "not >> allowed operation" symbol when the file being dropped is over the .pl >> file. >> What do I have to do to the .pl file to make it work like the .bat file? > > If you've a version of ActiveState's Perl installed have a look into its > bin-directory. You will find a small tool named "pl2bat.bat" which wrap > your perl code into a batch file. > > Otherwise you can add a new key to your windows registry to imitate the > behavior of batch files. Then you can drag and drop your files directly > to you perl script. Just create the key > > HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\ > > with default value set to "". > Don't ask something about this CLSID, for me this works on a german > winxp machine. Perhaps you wanna compare this with your own system > settings. I've copied this value from > > HKEY_CLASSES_ROOT\batfile\shellex\DropHandler\ > > regards, > fabian Thanks. I tried both options and they both work so I will go with drag and drop directly onto the Perl script. As per your example I used the DropHandler value from "batfile". I wonder if there is a more appropriate value for "Perl"? ## Re: Drag and drop > .... >> Otherwise you can add a new key to your windows registry to imitate >> the behavior of batch files. Then you can drag and drop your files >> directly to you perl script. Just create the key >> >> HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\ >> >> with default value set to "". .... > Thanks. I tried both options and they both work so I will go with drag > and drop directly onto the Perl script. As per your example I used the > DropHandler value from "batfile". I wonder if there is a more > appropriate value for "Perl"? No. That is the excutable drag & drop handler. A quick look through the registry would have shown you that that value is the same for exe, pif etc files as well. Sinan ## Re: Drag and drop Tino wrote: > I would like to be able to drag and drop files onto a .pl file in the same > way I can drop files onto a .bat file. I made a .bat which can do this but > if I try to do the same thing with a .pl file I find the .pl file isn't able > to accept files for drag and drop operations, the cursor changes to the "not > allowed operation" symbol when the file being dropped is over the .pl file. > What do I have to do to the .pl file to make it work like the .bat file? > > Example of .bat file onto which a file can be dropped: > > @echo off > :plot_loop > print.pl p=1 %1 > shift > if not "%1"=="" goto plot_loop > > > Example of .pl file that I would like to do the same as the .bat file: > > use strict; > use warnings; > > foreach (@ARGV) { > system("print.pl p=1$_");
> }
>
>

Not the exact answer to your question; but if you just need to _get the
job done_, two alternatives are

1. use the following one-liner batch file that calls the perl script in
turn.

@perl "path\to\script\thescript.pl" %*

2. consider compiling the perl script in to a Windows executable.