Hi all, I have a script that works as designed, but when I pack it into an .exe with PAR::Packer, it crashes at an open command. I'm on Windows, using ActivePerl.
I'm also at a complete loss. Am I doing something wrong? Did I stumble upon some weird incompatibility/bug? Is my PAR::Packer install broken?
Here's a shortened version of the script that exhibits the problem:
use strict; use warnings; use Tk; use utf8; my $mw = Tk::MainWindow->new; $mw -> Button(-text=>"Exit", -command => sub {exit(0)}) -> pack(-pady +=> 20); my $convert_bin; my $condition; if (!$condition) { my $bin_win = $mw->Toplevel(-title => 'A toplevel'); $bin_win->minsize(300, 200); $bin_win->update; $bin_win->raise; $bin_win->focus; $bin_win ->Label( -text => "Just testing", -font => 'bold',)->pack +(-pady => 10); $bin_win ->Label( -text => "Please click browse and specify a rand +om file.\nThe script will try and print the file path to c:/test/file +path.txt.",)->pack(-pady => 10); my $filepicker = sub { # this sub is launched when the Browse b +utton is pressed, see further down $convert_bin = $mw ->getOpenFile( -title => "Please choose the file", -multiple => 0, ); mkdir "c:/test"; open (OUT, ">:encoding(UTF-8)", "c:/test/filepath.txt") or pri +nt "Can't open file: $!"; # this fails when the script is packed i +nto an exe with PAR::Packer print OUT "File path: $convert_bin"; close OUT; $bin_win->destroy; }; # don't delete this ; my $buttbrowse = $bin_win -> Button(-text=>"Browse", -command =>[\&$fi +lepicker]) -> pack(-pady => 20); } MainLoop;

P.s. it creates a random folder on c:/, it was the first location that came to mind.

In reply to Filehandle open fails in script packed with PAR::Packer by elef

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.