What is -f>@+?*<.-&'_:#/%! in Perl?

Back in 2009, someone posted a question on Stackoverflow asking:

How do you google for "-f>@+?\*<.-&'_:$#/%!"?

The poster was actually trying to figure out what -f>@+?*<.-&'_:$#/%! did in Perl, but before I knew it, the question had been migrated to SuperUser as a question about how to use Google. It has been moved again, and now it lives on WebApps.

I felt like I did a good job going through the expression the first time, and I really do not want my explanation to be lost in the StackExchange maze. So, here it is:

Writing -f>@+?*<.-&'_:$#/%! out piece by piece, we have:

  • -f: perldoc -f -X. If no file name is specified (as is the case here) checks if $_ contains the name of a plain file

  • >: Checks if the RHS LHS is greater than the LHS RHS (thanks MartinS for noticing the error)

  • @+: In scalar context, returns the number of elements in @+

  • ?: the conditional operator

  • *<: The glob for main::<

  • .: String concatenation operator

  • -&'_: Invokes a function main::_. FYI, ' is the Perl4 style package name separator. Try perl -MHTML'Template -e 1.

  • : : Continuing with conditional operator

  • $# : The output format for printed numbers

  • / : Division operator

  • %! : %ERRNO; see perldoc -v '%!'

PS: See also notes on how to write maintainable Perl: “Basically, if you think Perl is -f>@+?*<.-&'_:$#/%!, and you aspire to write stuff like that in production code, then, yeah, you'll have problems.”

PPS: I also wrote a blog post on writing readable and maintainable Perl for O'Reilly.