Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Strictly frustrating !

by marto (Cardinal)
on Jul 26, 2013 at 14:49 UTC ( [id://1046528]=note: print w/replies, xml ) Need Help??


in reply to Strictly frustrating !

This isn't "abuse" by any means. When you have use strict; you have to declare variables. Your example above shows you're not being consistent in your approach. Some variables are declared, for example my $string=shift; while others aren't. Declare %hash, $kv and $vv before you use them. See also:

Replies are listed 'Best First'.
Re^2: Strictly frustrating !
by PearlsOfWisdom (Initiate) on Jul 26, 2013 at 14:57 UTC
    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.

      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"; }
Re^2: Strictly frustrating !
by marinersk (Priest) on Jul 26, 2013 at 16:02 UTC
    At a guess, I think the OP's use of the term "abuse" may be language-oriented, though it could simply be a manifestation of frustration. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-19 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found