Twigils and special variables


I could not find a better place yet to introduce them so let me do it now. Perl 6 has a large set of special variables. In order to make it easy to differentiate them from regular variable they are marked with what we call a twigil. Regular, user defined variables have a sigil ($, @ or %) in front of them. System variables have and additional character between the sigil and the name of the variable.

Examples:

  • $*PROGRAM_NAME

    contains the path to the currently running Perl 6 script.

  • $*CWD

    contains a path to the current working directory.

  • $*IN

    Is the standard input (STDIN). You can read a line using $*IN.get

You can read more about them in S28 http://perlcabal.org/syn/S28.html


Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC
If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed