Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Strictly frustrating !

by PearlsOfWisdom (Initiate)
on Jul 26, 2013 at 14:57 UTC ( #1046532=note: print w/replies, xml ) Need Help??


in reply to Re: Strictly frustrating !
in thread Strictly frustrating !

hmmm... that seems to have fixed it in that example code, but when I paste those paras back into my main program it starts moaning again at those exact lines. I get the feeling I'm going to have to start again from a blank sheet of vi. ;-( Thanks for dropping by with your thoughts.

Replies are listed 'Best First'.
Re^3: Strictly frustrating !
by marto (Cardinal) on Jul 26, 2013 at 15:00 UTC

    If the line numbers and errors reported are the same then I can only suspect that you haven't saved the file. Is this the whole program? If not please pase the exact code and the output you get when running it.

      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"; }

        In addition to declaring your variables with my (as others have pointed out), you're not properly de-referencing your array or hash references. This

        foreach my $k (keys %{hash}) {
        should be
        foreach my $k (keys %{$hash}) {
        (and same for de-referencing the array reference in doArrayTidy).

        -derby

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1046532]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-12-10 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?