Global symbol "%hash" requires explicit package name at test_do_archiv
+e2.pl line 68.
Global symbol "%hash" requires explicit package name at test_do_archiv
+e2.pl line 70.
Global symbol "%hash" requires explicit package name at test_do_archiv
+e2.pl line 72.
Global symbol "@array" requires explicit package name at test_do_archi
+ve2.pl line 79.
Execution of test_do_archive2.pl aborted due to compilation errors.
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use UUID::Tiny;
use Sys::Syslog qw( :DEFAULT setlogsock);
use POSIX qw/strftime ceil/;
use Storable qw/dclone/;
use Digest::SHA qw/hmac_sha256 hmac_sha256_hex/;
use LWP;
use DBI;
use File::stat;
use HTTP::Request::Common qw/POST/;
use LWP::UserAgent::Determined;
delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
use sigtrap 'handler' => \&term_handler, 'normal-signals';
# Gen Config
# GETOPT
my $verbose;
my $datalist;
GetOptions ('verbose!' => \$verbose,
"datalist=s" => \$datalist);
# Term Hanlder
sub term_handler {
doLog("err","term_handler: Program terminated early due to user in
+put");
exit 2;
}
# DATE STUFF
$ENV{TZ} = "Z";
my @systime = localtime();
# Log sub
sub doLog {
my ($priority,$msg) = @_;
return 0 unless ($priority =~ /info|err|debug/);
setlogsock('unix');
openlog("do_archive.pl", 'pid,cons', 'user');
syslog($priority, $msg);
closelog();
return 1;
}
# Debug
sub doDebug {
my ($header,$content) = @_;
if ($verbose) {
doLog("debug",$header.": ".$content);
print "################".$header."#################\n".$content."\
+n"."##################################\n";
}
}
# String Trim
sub doStringTrim {
my $string=shift;
$string =lc($string);
$string=~s/^\s+//;
$string=~s/\s+$//;
return $string;
}
sub doHashTidy {
my $hash=shift;
foreach my $k (keys %{hash}) {
my $kv=doStringTidy($k);
my $vv=doStringTidy($hash{$k});
delete $hash->{$k};
$hash{$kv} = $vv;
}
}
#ArrayTidy
sub doArrayTidy {
my($array) = @_;
foreach (@{array}) {
$_=lc($_);
s/^\s+//;
s/\s+$//;
}
}
my %hash=("X"," t ");
doHashTidy(\%hash);
foreach my $key ( keys %hash )
{
print "key:$key, value:$hash{$key}\n";
}
-
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.