in reply to Perl ERROR for uninitiated value or string

Please help me!!!

Which lines are 571,572,573,574? One of the variables on that line is undef

To figure out which one is undef use ddumperBasic debugging checklist Basic debugging checklist item 4

To figure out why those vars are undef also use ddumperBasic debugging checklist Basic debugging checklist item 4

  • Comment on Re: Perl ERROR for uninitiated value or string

Replies are listed 'Best First'.
Re^2: Perl ERROR for uninitiated value or string
by waytoperl (Beadle) on Nov 27, 2013 at 03:21 UTC

    Since I'm dumping $inc1 .... $inc12 to a text file, they values are read. Additional to these I've another function that reads data from a file and stores it in a array. After storing in array I'm printing these array. Here comes the problem, script is not printing.

    Code I'm using to create a array is:

    while (<$infile_lib1>) { if ($_ =~ /values \( \/ /) { $line = <$infile_lib1>; @DIN_SETUP_RISE_1 = split /,/,$line; print "@DIN_SETUP_RISE_1 \n"; $line = <$infile_lib1>; @DIN_SETUP_RISE_2 = split /,/,$line; print "@DIN_SETUP_RISE_2 \n"; $line = <$infile_lib1>; @DIN_SETUP_RISE_3 = split /,/,$line; print "@DIN_SETUP_RISE_3 \n"; } }

    Input file have these values:

    values ( \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ );

    Some how I'm not able to create an list of array for each line read, split and assign to array. Perl does not report any error when I execute code, and array is not getting print. I've used all debug tools available, like strict, warnings, diagnostic...please help!!

      use more ddumper
      #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; my $samplefile = q{ values ( \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ "0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.56789123, 0 +.67891234, 0.78912345", \ ); }; my @DIN_SETUP_RISE_1; my @DIN_SETUP_RISE_2; my @DIN_SETUP_RISE_3; open my($infile_lib1), '<', \$samplefile; while (<$infile_lib1>) { if ($_ =~ /values \( \/ /) { my $line = <$infile_lib1>; @DIN_SETUP_RISE_1 = split /,/,$line; print "@DIN_SETUP_RISE_1 \n"; $line = <$infile_lib1>; @DIN_SETUP_RISE_2 = split /,/,$line; print "@DIN_SETUP_RISE_2 \n"; $line = <$infile_lib1>; @DIN_SETUP_RISE_3 = split /,/,$line; print "@DIN_SETUP_RISE_3 \n"; } else { dd( nomatch => $_ ); } } dd( DIN => \@DIN_SETUP_RISE_1, \@DIN_SETUP_RISE_2, \@DIN_SETUP_RISE_3 +); __END__ ("nomatch", "\n") ("nomatch", "values ( \\\n") ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ( "nomatch", " \"0.1234567, 0.2345678, 0.3456789, 0.4567891, 0.5678912 +3, 0.67891234, 0.78912345\", \\\n", ) ("nomatch", " );\n") ("DIN", [], [], [])
        How can I read these values and create array associated to these line?
      What is $line, where does that variable come from?