How does --$| work in Perl?

后端 未结 4 1124
太阳男子
太阳男子 2020-12-11 00:43

Recently I came across this way to filter out every second value of a list:

perl -E \'say grep --$|, 1..10\'
13579

How does it work?

4条回答
  •  不知归路
    2020-12-11 01:23

    The point is this use is just a nasty hack.
    $| ( or his more readable alias $OUTPUT_AUTOFLUSH) is a special variables to control the autoflush of STDOUT ( or the current selected filehandle). Therefore it only accepts true (1) or false (0).

提交回复
热议问题