KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array @myarray and a hash %myhash , why do you need to do: $x = $myarray[1]; $y = $myhash{'foo'}; instead of just doing : $x = myarray[1]; $y = myhash{'foo'}; Why are the above ambiguous? Wouldn't it be illegal Perl code if it was anything but a $ in that place? For example, aren't all of the following illegal in Perl? @var[0]; @var{'key'}; %var[0]; %var{'key'};
Tags (comma-separated)
Save Edits
Cancel