The scalar variable $a will be unrelated to the array variable @a.
$a will denote the third element in the @a array, and will be unrelated to $a.
The variable will come into existence with a default initial value.
A scalar variable will have the undef value. Inside a numerical operation it will be regarded as 0, and inside a string operation it will be regarded as an empty string "".
An array variable will become an empty list, ().
The scalar value will become the single element of the array.
#!/usr/bin/perl @array = 5; # same as @array = (5); $n = 7; @array = $n; # same as @array = ($n);
I assign an array variable into a scalar variable?
The scalar variable will contain the number of elements in the array.
@array = ("Dafna", "Michal", "Rina"); $var = @array; # $var is now 3;