Identifiers
Learn the basics of identifiers/naming conventions in the Perl language.
We'll cover the following...
Names
Names (or identifiers) are everywhere in Perl programs. They exist primarily for our benefit as programmers; we choose them for variables, functions, packages, classes, and even filehandles. All valid Perl names begin with a letter or an underscore and may optionally include any combination of letters, numbers, and underscores. When the utf8
pragma is in effect, we may use any
These are valid Perl identifiers:
my $name;my @_private_names;my %Names_to_Addresses;sub anAwkwardName3;
This works with utf8
pragma enabled:
use utf8;package Ingy::Döt::Net;
These are invalid Perl identifiers:
my $invalid name; # space is invalidmy @3; # cannot start with number my%~flags; # symbols invalid in namepackage a-lisp-style-name; # use underscore instead
Note: Names exist primarily for our benefit as a programmer.
These rules apply only to literal names that appear in our source code, such as sub fetch_pie
or my $waffleiron
. ...