@ usually defines an array
"shift" is a function that removes and returns the first element of an array. If no array is used with the function it removes and returns the first element of the system array: @_, which is used to pass arguments to subroutines. Perl has two very special variables:
$_
@_
whenever a perl functon is used without a specific variable perl almost always assumes $_ or @_ depending on the context. Which is why something like this works:
the print function is not using any argument so perl assumes $_. Same with the for() loop. Perl assigns each element of @array to $_ if you do not specify a variable like below:
- foreach my $var (@array) {
-
print $var;
-
}
Dont get into the habit of using $_ and @_ too much and relying on perl to do what is right. At first it seems tempting to write code like the first example above, but in reality it's not good practice.
$1 and $2 (up to $9 I believe) are special variables perl uses to store pattern matches of regular expressions in memory. They are read only variables, which means they can not be modifed inplace.
- $foo = 'foo';
-
$foo =~ m/^(.)/;
-
print $1; (prints 'f');
Your questions above indicate you are jumping around considerably. Data types should be the first chapter or near first of any perl tutorial or book. Stuff like "shift" and $1 will come later after you are familiar with the basic stuff.
You should read a perl book, here is a free online book:
Beginning Perl