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

后端 未结 6 1880
陌清茗
陌清茗 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:23

    • Because Perl was intended to replace shell scripts, and variables in shell start with $.
    • To distinguish between scalars ($), arrays (@) and hashes (%).

提交回复
热议问题