http://qs1969.pair.com?node_id=1220694

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

Hi This code
#!/usr/bin/perl -w use strict; use DateTime::Format::ISO8601; use DateTime::Format::Strptime; use Data::Dumper; my $di = DateTime::Format::ISO8601->parse_datetime('2018-08-20T06:43:5 +0.330Z'); my $dv = DateTime::Format::ISO8601->parse_datetime('2018-08-20T06:46:5 +6.147Z'); my $delta = $dv - $di; print Dumper $delta;
works fine in perl interpreter 5.16
but when i make a binairy with PerlApp it gives me following error

ERROR:
DateTime/Format/Builder/Parser.pm line 164. DateTime::Format::Builder::Parser::create_single_parser(undef, 'params', 'ARRAY(0x297e3dc)', 'length', 8, 'regex', 'Regexp=REGEXP(0x479be24)') called at /

DateTime/Format/Builder/Parser.pm line 305 DateTime::Format::Builder::Parser::sort_parsers('DateTime::Format::Builder::Parser', 'HASH(0x479372c)', 'ARRAY(0x4790cb4)') called at /

DateTime/Format/Builder/Parser.pm line 228 DateTime::Format::Builder::Parser::create_multiple_parsers('DateTime::Format::Builder::Parser', 'HASH(0x479372c)', 'HASH(0x479be04)', 'HASH(0x479bee4)', 'HASH(0x479bf94)', 'HASH(0x479c034)', 'HASH(0x479c0e4)', 'HASH(0x479c204)', 'HASH(0x479c314)', ...) called at /

DateTime/Format/Builder/Parser.pm line 362 DateTime::Format::Builder::Parser::create_parser('DateTime::Format::Builder::Parser', 'ARRAY(0x478cf1c)', 'HASH(0x479be04)', 'HASH(0x479bee4)', 'HASH(0x479bf94)', 'HASH(0x479c034)', 'HASH(0x479c0e4)', 'HASH(0x479c204)', 'HASH(0x479c314)', ...) called at /<\datetimeproblem.exe>DateTime/Format/Builder.pm line 122 DateTime::Format::Builder::create_parser('DateTime::Format::Builder', 'ARRAY(0x47a2c04)') called at /<\datetimeproblem.exe>DateTime/Format/Builder.pm line 132 DateTime::Format::Builder::create_end_parser('DateTime::Format::Builder', 'ARRAY(0x47a2c04)') called at /

DateTime/Format/Builder.pm line 78 DateTime::Format::Builder::create_class(undef, 'parsers', 'HASH(0x47a38fc)') called at /<\datetimeproblem.exe>DateTime/Format/ISO8601.pm line 173 eval '' called at perlapp line 831 PerlApp::safe_eval() called at PerlApp/myrequire.pl line 102 PerlApp::my_require('DateTime/Format/ISO8601.pm') called at datetimeproblem.pl line 3 main::BEGIN() called at /<\datetimeproblem.exe>DateTime/Format/ISO8601.pm line 0 eval {...} called at /<\datetimeproblem.exe>DateTime/Format/ISO8601.pm line 0 BEGIN failed--compilation aborted at datetimeproblem.pl line 3.


Thanks for your Help
Harry C

Replies are listed 'Best First'.
Re: Active perl Perlapp problem
by anonymized user 468275 (Curate) on Aug 20, 2018 at 10:09 UTC
    According to the docs, "PerlApp first determines which modules and external files the converted script depends upon. The PerlApp program starts this process by scanning the script source code". Problem is that promise does not include whatever source code the dependent modules are themselves dependent on. So my best guess is you have to put in a use or require specifically for each indirect dependency.

    Update: Just seen an intervening post with --add, hmm having googled for it I found only one minus i.e. -add. oh well, might be preferable to use such an option)

    One world, one people

Re: Active perl Perlapp problem (perlapp --add DateTime::** ... foo.pl )
by Anonymous Monk on Aug 20, 2018 at 10:07 UTC
Re: Active perl Perlapp problem
by Marshall (Canon) on Aug 21, 2018 at 19:19 UTC
    Sometimes when you have something like this:
    use DateTime::Format::ISO8601; use DateTime::Format::Strptime;
    You need these statements before that also:
    use DateTime; use DateTime::Format; #maybe even this also
    I prefer to add use statements to the source code rather than adding options to the perlapp command.

    Update: BTW I prefer the PerlApp GUI instead of the command line. Type "perlapp" with no parameters to start it.

      Have you tried DateTime::**?
        I guess you are the same anon Monk who wrote:
        perlapp --add DateTime::** ... foo.pl

        No I didn't test that. However, it looks like it would work.

        As I explained, I prefer to modify the source code so that this "--add" option is unnecessary. This has the benefit of eliminating one extra piece of info to keep track of! After the usual activity around the first release, some of my apps can run for 4-5 years before I get a bug report or feature request. A lot can change over the years (Perl version, PerlApp version, other dev environment things, predominate user platform, etc). If I have to revisit a piece of code, I will rebuild the .exe using the latest Perl and Perlapp versions and of course use my QA testing process. If perlapp just runs without requiring any special options, so much the better for me.

        BTW, I don't use the Perlapp command line anymore. Run the GUI by just hitting CR after PerlApp.

        At the end of day, there is more than one way to solve this problem. I have good reasons based upon 20 years of experience for why I do what I do. However this doesn't have to be a "one size fits all" situation.

Re: Active perl Perlapp problem
by harryC (Sexton) on Aug 20, 2018 at 10:25 UTC
    Hi
    I use
    perlapp --add DateTime:: --norunlib --exe datetimeproblem.exe --perl c:\perl\bin\perl.exe datetimeproblem.pl
    RGDS Harry C
      Does adding ** fix it ?
        No it did not but i changed the code to Date::Manip so my problem is solved
        Thank for your help
        use Date::Manip::Date; my $obj = new Date::Manip::Date; $obj->parse('2017-07-20T06:43:50.330Z'); my $obj1 = new Date::Manip::Date; $obj1->parse('2018-08-20T06:46:56.147Z'); my $delta = $obj1->calc($obj);