in reply to Re: Perl ERROR for uninitiated value or string
in thread Perl ERROR for uninitiated value or string

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!!

Replies are listed 'Best First'.
Re^3: Perl ERROR for uninitiated value or string
by Anonymous Monk on Nov 27, 2013 at 03:34 UTC
    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?

        How can I read these values and create array associated to these line?

        The way you've been trying to do, except fix the part that isn't working

        Do you know which part?

Re^3: Perl ERROR for uninitiated value or string
by Anonymous Monk on Nov 27, 2013 at 03:30 UTC
    What is $line, where does that variable come from?