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 various uses of perl?
How many types of primary data structures in Perl and what do they mean?
What are the purpose of close(), getc() and read() functions?
How to implement a stack in Perl?
What are the functions that can be performed using cgi program?
Which functions in perl allows you to include a module file.
Explain goto expr?
What is stdin in perl?
What is perl pop array function?
What does init 5 and init 0 do?
What is a perl references?
How the interpreter is used in Perl?
Explain the execution of a program in perl.
What does the’$_’ symbol mean?
How to dereference a reference?