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
Define say() function in perl?
Explain the meaning of perl one-liner?
What is perl shift array function?
What is -> symbol in perl?
How do I do fill_in_the_blank for each file in a directory?
What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?
Explain the internal working of cgi
How to renaming a file in perl programming?
Explain goto expr?
What $! In perl?
How will you create a file in perl?
What are the steps involved when the cgi program starts running?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
what is Polymorphism in Perl?