Why do Perl variables need to start with $, %,@ (sigils)?

后端 未结 6 1899
陌清茗
陌清茗 2020-12-05 00:47

Why do Perl variables need to start with different characters (sigils)?

  • Scalar variables start with $

  • Hashes start with %

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 01:14

    Not all of them do, some start with % (hashes) or with @ (arrays).

    It is a design decision to mark them as variables and also denote their type.

    Note that you can have both a $abc and a %abc.

    Check out a tutorial on Perl variables.

提交回复
热议问题