in reply to Re: Cava Packager quick question
in thread Cava Packager quick question

$0 is used for Windows Registry entries to invoke my application from other applications. $0 variable allowed me to use my application without knowing what I'm actually running (.exe or .pl)

Replies are listed 'Best First'.
Re^3: Cava Packager quick question
by SuicideJunkie (Vicar) on Mar 25, 2010 at 19:58 UTC

    Could you not set a registry entry with "perl script.pl" vs "script.exe" when you install your script? Another thing you might do is set the associations so that .pl files are opened with the perl interpreter (just say "script" and away you go). You could also place a batch file in the directory to launch whatever style you've installed (run startscript.bat).

    I'm not really sure how $0 helps you there however... you'd have to run your application to populate $0 in the first place, and at that point you're already running the code so you must have found it. Chicken vs Egg.

      in my script I have '--install' option and the code determines if we are .exe or .pl and then writes to Registry '$0' or 'wperl $0'

      Of course it is not a problem, but now it is less flexible because I had to define the application's name in configuration file.
        Of course it is not a problem, but now it is less flexible because I had to define the application's name in configuration file.

        1) If $0 is wrong, its a bug/deficiency in cava packager, submit a bug report

        2) usually registry entries are handled by installer programs

        3) This is a flexible workaround

        $ cat myregular.pl use MySuperApp; MySuperApp->run; $ cat mypackedapp.pl BEGIN { use Cava::Pack; $0 = $Cava::Pack::EXEPATH; } use MySuperApp; MySuperApp->run;