Rulz user variables are one or more lowercase letters. They are assigned by the set operator and referenced with $. Like PHP, variables can have any type.
= var 100 = var "foo" = var (1,2,3) ^ value is $var
Like Perl, Rulz has "Special Variables". Unlike Perl none have named versions nor have any associated mnemonics.
$0 default or return value for some operators and builtins $_ default or return value for some operators and builtins $. end of line terminator ('<br>' or "\n") $; argument separator for the print function (' ') $, array separator for the print function (',') $[ PHP version string $] Rulz code version string $| Rulz language version string $^ debugging value (see CLI) $$ CLI program name ('./rulz') $1-9 search subexpression matches $& string that matched for search $# number of matches for search $` loaded Rules file name $/ value of __DIR__ (with appended directory separator) $} name of running loop $> TRUE if running in a terminal $~ currently running Rule name $- current rule string $< previous rule string $= current Rule line number $! last Rulz error string $% error diagnostic rule - run upon error $* string derived from the uname function $+ exec/system command output $( the key for @each $) the value for @each
Special variables can be assigned like variables, without the
= , ', ' set $, to the string ', ' = ^ 1 set $^ to 1
(A space after
= is only required to avoid ambiguity with operators that begin with
=.) A few special variables are read only.
@! hash of all special variables @$ hash of all variables @% hash of all internal variables @& list of a subroutine names
These are read only and useful only for diagnostic purposes.
Like PHP, Rulz has some "Super Globals", but in name only and are referenced by name preceded with the @ operator followed that the variable name, with an optional value for assignment.
@ENV hash of all environment variables @ENV HOME read variable @ENV FOO BAR set variable
@SERVER hash of all server variables @SERVER SCRIPT_NAME read variable
(PHP version only.)
(PHP version only.)
Also called "Internal Variables", these are like Shell variables. They are interpolated in double quoted strings. Most are read only.
$ARGS arguments passed to program $HOME same as @ENV HOME $INC include path $PATH same as @ENV PATH $CWD result of getcwd() $PWD previous working directory (cd) $RAND random number $TIME current timestamp
The assignment operator is used to set an internal variable.
= LOOPMAX 100
Most internal variables are read only.