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 is goto statement in perl?
what are the three groups involved in information sharing?
What are the arguements we normally use for perl interpreter?
What is it meants by '$_'?
How to close a directory in perl?
what are steps to do to lock the sony ericsson mobile with password?
explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.
How do I replace every character in a file with a comma?
What is a perl references?
Create a function that is only available inside the scope where it is defined ?
you are required to replace a char in a string and store the number of replacements. How would you do that?
How to know whether a key exists or not in perl?
Explain chomp?
How to prevent file truncation in perl?
What are scalar data and scalar variables?