You can also go through our other suggested articles to learn more —. Submit Next Question. By signing up, you agree to our Terms of Use and Privacy Policy. Forgot Password? This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy.
Popular Course in this category. Course Price View Course. Free Software Development Course. So, to be clear, if you absolutely have to have parentheses for your print , do this:. Another danger of the syntax is that the parser expects a single scalar expression as the object. Printing to a filehandle stored in an aggregate variable seems obvious, but it is not:.
This was fine when filehandles were package globals, but lexical filehandles Filehandle References make the indirect object syntax problems obvious. To solve this, disambiguate the subexpression which produces the intended invocant:.
It's how the syntax of print is defined. It's really that simple. There's kind of nothing to fix. Yes, that looks really weird. It is really weird.
If what you're trying to do is get parentheses around the arguments to print to make it look more like an ordinary function call, you can say. The key point is that including the comma changes the parse. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to tell perl to print to a file handle instead of printing the file handle?
Ask Question. Asked 9 years, 1 month ago. How to Calculate and display total balance in each account using hash in perl. Without using parse function. This printed out the file handle reference to stdout, not what I had in mind. After reading lots of different web pages and trying various weird variants, I finally figured out that the problem was the comma.
Remove the comma and it works. Save my name, email, and website in this browser for the next time I comment. Notify me of followup comments via e-mail.
Previous post: How to Backup Linux? All rights reserved Terms of Service. In this article, let us discuss how to manipulate the file handlers in Perl.
0コメント