in reply to Re: split, Use of uninitialized value
in thread split, Use of uninitialized value

Some definitions ...

use constant IMP_WG => 18; use constant CSC_HAN => 19;

And a dumped record with some data blanked out.

CSC.MIDRANGE.SERVER.SUPPORT 1 $VAR1 = [ 618, 'xxxxxxxxxx', '3-Moderate', 'Normal', 'Closed', 'xxxxxxxxxx', 'xxxxxxxxxx', 'Approved', 'Approved', '05/12/03 10:00', '02/12/03 09:45', '3.00', 'Successful', '12/12/03 09:53', '05/12/03 13:00', '05/12/03 09:52', 'Midrange', 'Production', 'CSC.MIDRANGE.SERVER.SUPPORT', 1 ]; Use of uninitialized value at stats2 line 192.

As far as I can see in all cases the data I am testing does exist. I previously had the final test as $rec->[CSC_HAN] == 1 but that was one of the first things that I changed.

I cant see any scope for autovivification either ... the only possibility would be $rec but then the print statement should be throwing the uninitialised value errors.

If it matters (and it probably does with something this weird) $rec is a local copy of a pointer stored in a hash and obtained like so:

my $rec = $change_recs{$key};

Replies are listed 'Best First'.
Re: Re: Re: split, Use of uninitialized value
by Roger (Parson) on Jan 07, 2004 at 04:02 UTC
    What's SRV_PLT defined as?

    I defined a new out of range index3 in the following example -
    #!/usr/bin/perl -w #use strict; use Data::Dumper; use constant index1 => 18; use constant index2 => 19; use constant index3 => 20; my $rec = [ 618, 'xxxxxxxxxx', '3-Moderate', 'Normal', 'Closed', 'xxxxxxxxxx', 'xxxxxxxxxx', 'Approved', 'Approved', '05/12/03 10:00', '02/12/03 09:45', '3.00', 'Successful', '12/12/03 09:53', '05/12/03 13:00', '05/12/03 09:52', 'Midrange', 'Production', 'CSC.MIDRANGE.SERVER.SUPPORT', 1 ]; # @$rec = map { defined($_) ? $_ : '' } @$rec; # print Dumper($rec); if ( defined $rec->[index1] && $rec->[index1] ne '' && defined $rec->[index2] && $rec->[index2] eq '1' ) { if ($rec->[index3] == 1) { print "Crap\n" }; # +39 print "$rec->[index1] $rec->[index2] ", $rec->[index3], "\n"; # +40 print "OK\n"; } else { print "Not OK\n"; } # print Dumper($rec);

    And the output of an out of range index3:
    Use of uninitialized value at ./p09.pl line 39. Use of uninitialized value at ./p09.pl line 40. CSC.MIDRANGE.SERVER.SUPPORT 1

      D'oh

      Field 20 ... and commenting it out stops the error ... but I don't understand why the error message consistantly pointed at the if statement. If anyone can elucidate this I would love to hear the answer otherwise thankyou everyone for your efforts.

        Are you sure it's pointing at the if statement and not the print statement? ;-)