in reply to Indirect Object Syntax
chromatic nicely summarises the parsing problem here:
new Foo has two barewords, and whenever the Perl parser encounters barewords, it has to guess at what they are. Sometimes it has hints at what those barewords are (if it's encountered declarations of filehandles or subroutines) and it can guess correctly. Sometimes it doesn't have hints, because Perl embraces late binding.
See also:
- Turn off indirect object notation - Effective Perler article by brian_d_foy
- Perl Best Practices section 15.12 "Don't use the indirect object syntax"
- Perl Cookbook chapter 13, "A Warning on Indirect Object Notation" section
- Perl::Critic policy to prohibit indirect object call syntax
- How does Perl parse unquoted bare words? (SO by ikegami)
Related:
- Re: New Discovery!!! (sub call without parentheses) - Coding Style by me (2018) - why I always use parens when calling user-defined subroutines
Added later:
- "open" Best Practices by haukex (2019)
- Optional Subroutine Arguments Like in `print FILEHANDLE LIST` by mikkoi (2023)
- perlobj: Invoking Class Methods: Indirect Object Syntax (perldoc) - "We recommend that you avoid this syntax"
- The 'indirect' feature (perldoc)
- perl5360delta: use v5.36 (perldoc) - The 5.36 bundle also disables the features indirect ... will forbid ... the use of "indirect" method calls ... that cause more trouble than they're worth
- Guacamole by Sawyer X (CPAN) - a parser toolkit for Standard Perl
- Indirect Object Syntax (perldoc)
- Indirect Object Syntax by Bod (2021)
- Calling a sub without enclosing its argument inside brackets by syphilis (2024)
- Re: Calling a sub without enclosing its argument inside brackets by ikegami (2024) - solved via no feature qw( indirect ); ... or equivalently use v5.36; or use v5.38;
Quoting References
- Quote and Quote-like Operators (perldoc)
- quotes in Perl by apotheon (2004)
- Strings in Perl: quoted, interpolated and escaped (Perl Maven)
- Ways of quoting by Aaronrp (2020)
- Re: Ways of quoting by davido (2020) - heredocs
- Re^4: Ways of quoting by hippo (2020) - Baby Cart secret operator
Updated Apr 1 2024 : added new Quoting References section (not a prank)
In Section
Seekers of Perl Wisdom