What is the difference between $array[1] and @array[1]?
Answer Posted / kiruthikau
$array[1] represents a scalar value.
@array[1] represents array slicing.
@array[1] returns a list with one scalar value.
We should use $ when we want a scalar value.
If we want a list we need to use @.
If we use 'use warnings' then @array[1] will give the warnings
like ,Scalar value @array[1] better written as $array[1].
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What are the different string manipulation operators in perl?
Define perl scripting?
What is perl push array function?
What is the purpose of _package_ literal?
What is the easiest way to download the contents of a URL with Perl?
Explain goto name?
Why to use perl?
What is the main function of cookie server?
Who created perl?
How to connect to SQL server through Perl?
Comment on array slicing and range operator
What does delete function do in perl?
Which guidelines by Perl modules must be followed?
How to access parameters passed to a subroutine in perl?
Explain lexical variables.