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 lexical variable in perl?
Which operator in perl is used for the concatenation of two strings?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
What does undef function in perl?
Which has highest precedence in between list and terms? Explain?
How to implement a stack in Perl?
Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?
Why -w argument is used with perl programs?
What is perl? What is the basic command to print a string in perl?
What are some of the key features of objects in perl?
Explain chomp, chop, cpan, tk.
Difference between the variables in which chomp function work ?
How will you open a file in read-only mode in perl?
How does polymorphism work in perl? Give an example.
What is perl scripting?