Hi Monks,
I'm trying to package a script with pp to run it on another system as a binary file (with Perl itself and every modules I'm using included).
My problem is in the use of the module Getopt::Long... When I launch the script before it has been packaged, I got no trouble with my options, but once it's benn through pp, it runs endlessly (I'm at 100% CPU right now, 1,7GB out of 2GB of RAM and that for around one hour for a scrpit that connects to a system, retrieves data and print them in a file...) Without the packaging, it takes less than a minute to be completed...
Here is my script (only the fraction where I'm using the options I've passed) :
#!/usr/bin/perl
# $Id "Getopt::Long Test after packaging by pp" $
# $Revision: 0 $
# $Source /home/root-hjo/script.pl $
use strict;
use warnings;
use Getopt::Long;
use DateTime::Format::ISO8601;
my ($pstart, $ptype, $help);
GetOptions( "t=s" => \$ptype, "s=i" => \$pstart, "h" => \$help );
######################################################################
+#######
# MAIN
+ ###############################################################
+##############
check_input($pstart, $ptype, $help);
######################################################################
+#######
# FUNCTIONS
+ ###############################################################
+##############
#################################check_input##########################
+#######
sub check_input {
my ($date, $type, $help) = @_;
if ( ( (defined($type) == '0') || (defined($date) == '0') ) && (de
+fined($help) == '0') ) {
die qq{Error while calling script\nUSAGE : ./script.pl -t [D|W
+|M|S] -s [DATE]\n\n};
}
if (defined($help) == '1') {
print_usage();
die qq{\n};
}
else {
if (defined($type) == '1' ){
if (($type ne 'D') && ($type ne 'W') && ($type ne 'M') &&
+($type ne 'S') ) {
die qq{Error : the given period is not valid\n};
}
else {print qq{period OK\n}};
}
if (defined($date) == '1') {
check_date($date);
}
}
}
######################################################################
+#######
#################################check_date###########################
+#######
sub check_date {
my $s = $_[0];
my $date;
eval { $date = DateTime::Format::ISO8601->parse_datetime("$s"); };
if ( $@ ) {
die qq{Error : the date doesn't exist or is not like YYYYMMDD\
+n}
}
else {print qq{date OK\n}} ;
}
######################################################################
+#######
###############################print_usage############################
+#######
sub print_usage {
print qq{\n};
print qq{USAGE : ./script.pl -t <D|W|M|S> -s [DATE]\n};
print qq{\n};
print qq{ -t specifies the type of period for which the inf
+ormation\n};
print qq{ is retrieved\n};
print qq{ D scale : day\n};
print qq{ W scale : week\n};
print qq{ M scale : month\n};
print qq{ S scale : a few seconds\n};
print qq{\n};
print qq{ -s start date to retrieve data\n};
print qq{ (format YYYYMMDD)\n};
print qq{\n};
print qq{ -h displays this help then stops\n};
}
######################################################################
+#######
__END__
And here is the command I'm using to package my script :
# pp -o script -M Getopt::Long -M Params::Validate::XS -M Class::Load::XS -M DateTime::Format::ISO8601 -C script.pl
I'm not directly using Params::Validate::XS nor Class::Load::XS, but it won't simply package if I don't include them so...
And if it helps, here are my output while I'm running this script before packaging :
# ./script.pl -h
USAGE : ./script.pl -t <D|W|M|S> -s [DATE]
-t specifies the type of period for which the information
is retrieved
D scale : day
W scale : week
M scale : month
S scale : a few seconds
-s start date to retrieve data
(format YYYYMMDD)
-h displays this help then stops
# ./script.pl -t D -s 20121015
period OK
date OK
Regards, HJO
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.