in reply to Determining presence of odd number of hash elements, other syntax problems

Just do:
perl -w /path/to/script.pl
It'll warn about an odd number and give the location.
  • Comment on Re: Determining presence of odd number of hash elements, other syntax problems
  • Download Code

Replies are listed 'Best First'.
Re^2: Determining presence of odd number of hash elements, other syntax problems
by nicku (Novice) on Jul 20, 2011 at 10:47 UTC
    Just do: perl -w /path/to/script.pl

    The problem is that the warnings of Use of uninitialized value in string at... and Use of uninitialized value in concatenation (.) or string at... are quite overwhelming with uninitialised variables. The reported location is often many kilobytes of distance away from the actual error.

    $ cat test-w
    #! /usr/bin/perl
    
    use strict;
    use warnings;
    
    my %hash = (
        fred => {
    	qw( odd number of elem ents ),
        },
    );
    $ perl -wc test-w
    test-w syntax OK
    $ perl -we "require qq{test-w}"
    Odd number of elements in anonymous hash at test-w line 6.
    

    Is there a way to turn those uninitialised warnings off on the command line?

        Is there a way to turn those uninitialised warnings off on the command line?

        Yes, but I mean something like this (except actually working): perl -we 'use warnings;no warnings q{uninitialized}; do qq{$file}'