my $ / @ / %
Try it yourself →The sigil determines the variable type.
Syntax
my $skaler; my @arr; my %hash;
Description
$ is used for single values (scalars), @ for arr, % for hash. Local variables are defined with my. use strict; is a good practice.
Example
my $name = "HexLibrary"; my @numbers = (1, 2, 3); print "$name - $numbers[0]\n";
Expected output
HexLibrary - 1
When to use?
Storing all kinds of data.
Common mistakes
- ⚠️ Single element of array $arr[0] (sigil becomes $, not @).