How do I create drag-and-drop Strawberry Perl programs?

后端 未结 3 2280
梦如初夏
梦如初夏 2020-12-06 01:52

I\'ve got a Strawberry Perl program that accepts a single-file as a command-line argument. How can I set things up such that I can drag and drop the desired file onto the S

3条回答
  •  攒了一身酷
    2020-12-06 02:13

    Here's another alternative to a "wrapper", but it requires a slight modification to the perl script:

    1. Rename your script.pl script to script.cmd.
    2. Add the following to the top of the file:

    @SETLOCAL ENABLEEXTENSIONS
    @c:\path\to\perl.exe -x "%~f0" %*
    @exit /b %ERRORLEVEL%
    #!perl
    #line 6
    # ...perl script continues here...

    The script is run like any other batch file. The first three lines basically invokes Perl on the CMD file itself (%~f0, which only works if CMD extensions are turned on). The -x paremeter to perl.exe tells Perl to skip everything until the #!perl line. "#line 6" just aids in debugging.

    This is my preferred solution when I don't know much about the target system (and may not be able to edit the registry).

提交回复
热议问题