in reply to Use of uninitialized value in concatenation (.) or string at perl.pl line 216, <$file> line 18.

From your code, it looks like $options{c} contains the filename you want to read from, and $file is your file handle.

If the open fails for any reason, then the filehandle stored in $file will be undefined, but you are attempting to include it in the die error message.

In your die error message, you have said 'open', I suggest you change that to 'read from' so that the end user knows what the script it trying to do. Also, there is a feature of the die command, where if the die string is terminated with a newline, it is output literally, but if you omit the new line, you get the line number as well, which is helpful for debugging.

Line 3 of your code should probably read:

open $file, '<', $options{c} or die "could not read from '$options{c}' + $!";
  • Comment on Re: Use of uninitialized value in concatenation (.) or string at perl.pl line 216, <$file> line 18.
  • Select or Download Code