mark McWilliams wrote:
What is the following telling me , especially the
chunk 2?

Use of uninitialized value in pattern match (m//) at
./lo line 27, <> chunk 2

That means that the variable that is bound to the pattern match contains the value undef. "chunk 2" means that you are currently reading the second chunk from the file.


I used if (defined ... to get rid of a few other
errors.

Yes, but are you using the strict and warnings pragmas?


this is in reference to the following code edited to
reduce size

while (defined($in = <>))

Using readline (<>) in the while conditional is special in that the expression is already tested by defined().

$ perl -MO=Deparse -e'while ( $in = <> ) { print $in }'
while (defined($in = <ARGV>)) {
    print $in;
}
-e syntax OK


 {
    if ( $in =~ /MT /)
      {
        $/ = "";

You are changing the Input Record Separator to paragraph mode from *inside* the loop. Assuming that $/ has the default value of "\n" before the loop starts then you are reading a line at a time until a line contains the pattern /MT / and then you are switching to paragraph mode for the rest of the file which is why the warning says 'chunk' instead of 'line'.


if (defined $in)

That is redundant as the while loop conditional already tests $in with defined().


{ ($mt, $t1) = split('MT ',$in); }
if (defined $t1) { ($title,$dp) = split('DP ',$t1); }
if(defined $dp) { ($year,$other)= split("\n" ,$dp);}
if (defined $t1) { ($lo, $rest) = split ('LO ',$t1); }
if (defined $rest) { ($locate, $more) = split ('\t' ,
$rest);}

You may not be using split() correctly but it is hard to tell without seeing the actual data. Have you read the documentation on how split() works?


unless ($rest =~ /QA76/) #<= line 27

The warning means that the value of $rest is undef.


         {
     print "Title =>".  $title ."  published after =>
". $year . "="x80 ."\n";
         }

      }
 }

What values might be uninitialized if I used if
defined to finded the values?

Thank you very much for all your time and effort in
advance.

What web site might I visit were I could type in an
error message and get a better clue as to what it is
telling me?

You should have the perldiag.pod document installed on your hard drive which contains details on all warning and error messages.

perldoc perldiag


You can also use the diagnostics pragma to have perl print out a longer warning/error message.

perldoc diagnostics




John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to