in reply to "Use of uninitialized value" even though the value is defined

Please always use strict; use warnings; and declare your variables.

You don't check the success of the second open call. If the open() fails, there will be no lines in @fp0 (same if the file exists but is empty), and $fp will be undef.

You can also use autodie to prevent such errors.

Replies are listed 'Best First'.
Re^2: "Use of uninitialized value" even though the value is defined
by mandrake00 (Initiate) on Apr 01, 2011 at 10:12 UTC
    Thanks. Still @fp0 =<PASSFAIL> does not seem to accept the content of PASSFAIL. Any idea why?
      open(PASSFAIL,">>./instLvsOut/passfail.tmp")

      Because you are opening the file for output only and you can't read from that filehandle.

      To check whether the passfail.tmp file is empty, I tried the command system("cat ./instLvsOut/passfail.tmp"); just before the line @fp0 =<PASSFAIL>. It displayed the content of the file properly. It was not empty. Any idea why this code does not accept values in @fp0 =<PASSFAIL>