in reply to Re: Emoji Progress Spinners
in thread Emoji Progress Spinners

Can someone tell me where else this function chaining EXPR (chr hex) can be used in perl?

It's just a combination of function calls and map:

$ perl -MO=Deparse,-p -e 'map chr hex, @code_points' map(chr(hex($_)), @code_points);

The behavior of chr and hex can be achieved with the (_) prototype, though prototypes are one of those "only use this if you know what you are doing" kind of thing because they change how Perl code is actually parsed (see also).

Parentheses can be omitted in calls to subs which the compiler has already seen.

$ perl -wMstrict -le 'sub foo {} foo "bar"' # ok $ perl -wMstrict -le 'sub foo {} foo("bar")' # ok $ perl -wMstrict -le 'foo("bar"); sub foo {}' # ok $ perl -wMstrict -le 'foo "bar"; sub foo {}' # fails String found where operator expected at -e line 1, near "foo "bar"" (Do you need to predeclare foo?) syntax error at -e line 1, near "foo "bar"" Execution of -e aborted due to compilation errors.

The only thing special here is map and grep, which have as an alternative to their map {...} ... and grep {...} ... forms the map ..., ... and grep ..., ... forms. The former two can be emulated using prototypes (e.g. (&@)), while the latter two can't.

Replies are listed 'Best First'.
Re^3: Emoji Progress Spinners
by ikegami (Patriarch) on Feb 08, 2021 at 12:01 UTC

    Parentheses can be omitted in calls to subs which the compiler has already seen.

    And to named operators such as hex and chr.

    Seeking work! You can reach me at ikegami@adaelis.com