What pseudo-operators exist in Perl 5?

后端 未结 9 1545
孤城傲影
孤城傲影 2020-11-28 07:05

I am currently documenting all of Perl 5\'s operators (see the perlopref GitHub project) and I have decided to include Perl 5\'s pseudo-operators as well. To me, a pseudo-o

9条回答
  •  情书的邮戳
    2020-11-28 07:32

    Nice project, here are a few:

    scalar x!! $value    # conditional scalar include operator
    (list) x!! $value    # conditional list include operator
    'string' x/pattern/  # conditional include if pattern
    "@{[ list ]}"        # interpolate list expression operator
    "${\scalar}"         # interpolate scalar expression operator
    !! $scalar           # scalar -> boolean operator
    +0                   # cast to numeric operator
    .''                  # cast to string operator
    
    { ($value or next)->depends_on_value() }  # early bail out operator
    # aka using next/last/redo with bare blocks to avoid duplicate variable lookups
    # might be a stretch to call this an operator though...
    
    sub{\@_}->( list )   # list capture "operator", like [ list ] but with aliases
    

提交回复
热议问题