in reply to need an explanation
@a = ('a', 'b', 'c', 'd', 'e');
qw just "quotes words".
The second line is usually written as
$b = @a;
or, for more clarity,
$b = scalar @a;
Perl is sensitive to context. By assigning to a scalar value, you impose the scalar context on the right hand side of the assignment. Arrays return their size (number of elements) in scalar context. Using = () = here has no effect and is only confusing. Update: It is usually used to force list context, for example
$x = () = "abcdABCabA" =~ /a/ig; # Count A's regardless of case.
|
|---|