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

Hi, Ok, I think this is a perl2exe (www.perl2exe.com) bug but I figured I would post it here just in case anyone had already also run across this. I'm now using Open2 to create a child process for my perl program on win32, and I can't use both open2 *and* the -gui option on perl2exe at the same time.
I've paid for the full version of perl2exe, soley for the use of the -gui option really, and now I can't use it. Here is a perfect example of the problem. This first program is just one that open2's the second program (after compiled) and they talk back and forth a bit. If I compile this first program with the -gui option,the program starts and then dies right away without really doing anything that I can tell. It won't even print anything out if you run the exe from a console. But, if you just don't compile it with the -gui option, then it works great.
#!/usr/local/bin/perl -w print "got here!\n"; use Tk; use IPC::Open2; $| = 1; ###open2(\*IN, \*OUT, "$^X f2.pl"); open2(\*IN, \*OUT, "f2.exe"); my $mw = new MainWindow; $mw->Label(-text => 'Print file')->pack; my $font = $mw->Entry(-width => 10); $font->pack; my $filename = $mw->Entry(-width => 10); $filename->pack; $mw->Button(-text => 'make test1 file', -command => sub{print OUT "test1.txt\n";} )->pack; $mw->Button(-text => 'make test2 file', -command => sub{print OUT "test2.txt\n";} )->pack; $mw->Button(-text => 'Exit', -command => \&my_exit )->pack; MainLoop; sub my_exit { print OUT "die\n"; close IN; close OUT; exit; }

Here is the code for f2.exe which you can compile with our without -gui into f2.exe.
#!/usr/local/bin/perl -w use IPC::Open2; $| = 1; while ($line = <STDIN>) { last if ($line =~ /die/i); #print "child_got_this:$line"; chomp $line; open TTT, ">$line"; print TTT "file is $line\n"; close TTT; } exit;

Again, I think this is a problem with perl2exe, and they are looking into it, but I thought people here might like to know about this or like the challenge as well. Thanks!

Justin Eltoft

"If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

Replies are listed 'Best First'.
Re: Perl2exe bug??
by EvanK (Chaplain) on Sep 27, 2001 at 08:45 UTC
    I'm not sure how Open2() works, but i DO know the way perl2exe works, and if your problem occurs only when you use the -gui option, then it might be that Open2() uses command line functionality such as system(command) or backquotes (`command`), which are disabled by the -gui option in perl2exe. (a trade for having that ugly console window disappear, i'm afraid.) i could be wrong, but that's my guess...

    ______________________________________________
    RIP
    Douglas Noel Adams
    1952 - 2001

Re: Perl2exe bug??
by Eradicatore (Monk) on Sep 28, 2001 at 05:23 UTC
    UPDATE:Ok, well after talking with their tech support and reading their web site some more, it turns out the -gui option somehow does away with STDIN and STDOUT. Since the program I'm opening with IPC::Open2 needs to read from STDIN, this must somehow be related to the problem. What I don't understand though is on the original program, I'm not talking to STDOUT. I'm dealing with the read and write pointers that I send to IPC::Open2.
    Anyway, does anyone have any idea how to do basically the exact same thing open2 does but with sockets or pipes? I'll have to go back to the drawing board and look, but if someone else already knows, thanks!

    Justin Eltoft

    "If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

Re: Perl2exe bug??
by MZSanford (Curate) on Sep 27, 2001 at 15:47 UTC
    I have used perl2exe, but have not paid for the entire version yet, as i have only been testing with it for about two weeks. So far things are going well, but instead of -gui, i have been using the pure perl way of changing binaries from console to windows on this page. Admittedly, i have not used IPC::Open2() with this approach, but it might help you find the uid(0) of your problem.
    "They shall not overcome. Whoever told them that the truth shall set them free was obviously and grossly unfamiliar with federal law."
        -- John Ashcroft