i am learning perl, want to call a function, and pass 2 parameters to it, here is the code:
use strict;
use warnins;
sub test
{
my ($item) = @_;
print "$item\n";
}
test("hello world");
the result is : hello world
if i change the code to be like this:
my $item = @_;
then the result is: 1
what's the reason for the difference ? a little confused, i understand @_ is the parameter passed to function test when calling it, which is string "hello world", then why after assign @_ to $item, the result is 1, seems the length of the array @_, but ($item) is the parameter itself,