I have this sub-routine which has identifiers defined like
*VALID_NAME_REG_EX = \"[ a-zA-Z0-9_#.:@=-]+";
*MACRO_VALID_NAME = \"MACRO_VALID_NAME";
I looked into the file further. They are referenced as $MACRO_VALID_NAME
.
I guess it's substituting the value with right side of string, but I am not sure of this and want a confirmation.
A Perl identifier is a name used to identify a variable, function, class, module, or other objects. A Perl variable name starts with either $, @ or % followed by zero or more letters, underscores, and digits (0 to 9). Perl does not allow punctuation characters such as @, $, and % within identifiers.
$1 equals the text " brown ".
Perl variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.
*VALID_NAME_REG_EX = \"[ a-zA-Z0-9_#.:@=-]+";
The effect this has is to assign $VALID_NAME_REG_EX
as an identifier for the Perl string literal "[ a-zA-Z0-9_#.:@=-]+"
This is different from saying
$VALID_NAME_REG_EX = "[ a-zA-Z0-9_#.:@=-]+"
which copies the string into the space assigned to $VALID_NAME_REG_EX
so it may later be altered
Perl literals have to be read-only to make any sense, so the result of the assignment is to make $VALID_NAME_REG_EX
a read-only variable, otherwise known as a constant. If you try assigning to it you will get a message something like
Modification of a read-only value attempted
*
in perl denotes a typeglob
Perl uses an internal type called a typeglob to hold an entire symbol table entry. The type prefix of a typeglob is a * , because it represents all types. This used to be the preferred way to pass arrays and hashes by reference into a function, but now that we have real references, this is seldom needed.
The main use of typeglobs in modern Perl is create symbol table aliases. This assignment:
*this = *that;
makes
$this
an alias for$that
,@this
an alias for@that
,%this
an alias for%that
,&this
an alias for&that
, etc. Much safer is to use a reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With