Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am sure this is a very stupid question...but maybe I'm missing something. I use pdftotext.exe to convert PDF files to plain text. I pass the content of the PDF to a variable. I call the PDF converter from within a script

open (FILE, "$installation_folder/bin/pdftotext $path_to_PDF/$file_id +- |"); my $text = do { local($/); <FILE> };

This works pretty well. Now I compile my script into an exe. If a select the option Hide Console (as the script is part of a small GUI, and I don't want the console to be shown), the variable $text remains empty. (If I compile the script without hiding the console, everything is fine). What can I do? Thanks

Replies are listed 'Best First'.
Re: hiding console
by kcott (Archbishop) on Feb 28, 2014 at 13:01 UTC

    How do you "compile my script into an exe."?

    Is the "Hide Console" some sort of checkbox (or similar) provided by your compilation application or is that just a description.

    What OS are you using?

    With answers [from you] to those, a better answer [from us] may be forthcoming. In the interim, here's a guess.

    If you use pp with the '--gui' option, this may do what you want.

    Update: Add [from you] and [from us] as a clarification.

    -- Ken

      I am working on Windows (7), ActiveState 5.16 and PerlApp to compile. Yes I'm using the checkbox provided by the compilation application. Thank you

        I'm unfamiliar with "PerlApp". Maybe another monk can help you with that.

        The pp --gui option is intended for "MSWin32 platforms": a potential alternative, perhaps.

        -- Ken

Re: hiding console
by rminner (Chaplain) on Feb 28, 2014 at 14:52 UTC
    Just guessing - perhaps the problem will go away if you use this approach to hide the window:
    BEGIN { Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow +; }
    Then of course you shouldn't be using the --gui option of whatever compiler you are using.
Re: hiding console
by Anonymous Monk on Feb 28, 2014 at 16:41 UTC

    I guess PerlApp turns to wperl when selecting the option Hide Console. This works smoothly except for SDT, which won't have any function anymore. I now opted for the module Win32::HideConsole which does the job (even if consol is lunched for some seconds)