Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Syntax error when trying to use a hash value as a file stream specifierby BillKSmith (Monsignor) |
on Sep 02, 2022 at 20:36 UTC ( [id://11146643]=note: print w/replies, xml ) | Need Help?? |
The book "Perl Best Practices" (ISBN 0596001738) recommends that you always use braces around the file handle in a print statements to make it clear that you did not forget a comma. This practice would eliminate your problem as well.
Did you consider redirecting your default output with select rather than passing it as an argument? UPDATE: I believe that the OP is passing a file-handle to a subroutine using the method that his reference (Cookbook recipe 10.7) calls 'Named Parameters'. Using this method, the file-handle is stored as a value in a hash. He as asking for the syntax to use that value in a print statement. AnomalousMonk has provided the answer. My suggestion to use select to pass the file-handle to the subroutine would work, but I no longer recommend it.
Bill
In Section
Seekers of Perl Wisdom
|
|