in reply to Undefined value as a symbol reference

Have you tried a three-argument open?
open( my $INFILE, '<', 'templateHosts') or die "can't open file $!";
Also, are you certain that you've replicated the code exactly? From open:
If FILEHANDLE is an undefined scalar variable (or array or hash element), a new filehandle is autovivified, meaning that the variable is assigned a reference to a newly allocated anonymous filehandle. Otherwise if FILEHANDLE is an expression, its value is the real filehandle. (This is considered a symbolic reference, so use strict "refs" should not be in effect.)
It looks like the interpreter is regressing into this symbolic reference behavior, though this would presuppose your value is not null.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Undefined value as a symbol reference
by link867 (Initiate) on Jul 21, 2014 at 20:35 UTC
    Yes, I copied the syntax directly from the perldocs man page to get the two argument. When I try the three argument I get: Too many arguments for open at ./templateChecker.pl line 97, near "'templateHosts'
      It looks like this is a version issue. I tracked down the 5.8.0 documentation, and according to that version of perlopentut, it looks like three-argument open and indirect file handles were not yet implemented. You could try to use IO::Handle, or stick with bare word file handles, e.g.
      open (INFILE, 'templateHosts' ) or die "can't open file $!";
      or explicitly define your glob with Symbol:
      use Symbol; my $INFILE = gensym; open ($INFILE, 'templateHosts' ) or die "can't open file $!";
      You'll probably have to explicitly close your filehandle assuming you want that done before end of execution. I'd probably go for the last option, as it's the closest to modern syntax. Actually, I'd try and raise enough fuss to upgrade to a modern version of Perl, but I assume that's not an available option....

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        It looks like this is a version issue. I tracked down the 5.8.0 documentation, and according to that version of perlopentut, it looks like three-argument open and indirect file handles were not yet implemented.

        No, the code posted only requires perl 5.6.0

        If OP is getting an error he is not using perl 5.8.0

        The use Symbol; option worked like a charm! Thank you so much. And you are right, the team that supports internal servers doesn't let anyone touch "their" servers and never upgrades. -.- I have said something about it and their answer was use this server instead, xxx, but it had the same perl version on it. Anyway thank you for your time, now I can move on with this script!