in reply to Re: Interpolation of file handles in print
in thread Interpolation of file handles in print

The error is not caused by the print statement but by the open statement. This is documented.
perldoc -f open shows:
If FILEHANDLE is an undefined scalar variable (or array or hash element) the variable is assigned a reference to a new anonymous filehandle, otherwise if FILEHANDLE is an expression, its value is used as the name of the real filehandle wanted. (This is considered a symbolic reference, so "use strict 'refs'" should *not* be in effect.)
Note the parenthetical phrase: (This is considered a symbolic reference, so "use strict 'refs'" should *not* be in effect.)

Replies are listed 'Best First'.
Re^3: Interpolation of file handles in print
by BrowserUk (Patriarch) on May 17, 2005 at 11:09 UTC

    From the OP's post:

    I've assigned names for file handles I want to use into an array marctags but I can't work out the syntax to get the print command to use the values.

    And:

    just can't get it to use the file handles which I've opened to output to files on the disk.

    Perhaps you could explain your post in the light of thise quotes, because I do not understand you?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
      The OP had already posted code that utilized the format for print as specified in perldoc -f print
      for my $x (0..1) { print { $marctags[$x] } $tagdata[$x] ; }
      Then the OP stated:
      use strict will raise a : Can't use string ("FOO") as a symbol ref while "strict refs" error that i don't know how to avoid here... So use FileHandle may be better :)
      Your reply presented a change to the print statement which was working as last presented so I assumed (probably in error?) that you were replying to his error message.