What is the difference between $array[1] and @array[1]?
Answer / 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 |
How will you access an element of a perl array?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
What?s your favorite module and why?
How can arrays be tied?
You want to download the contents of a url with perl. How would you do that?
How would you trap error occurred in the perl program/file?
How can you create anonymous subroutines?
What is the difference between module and package?
What is the difference between having a parenthesis after module name and without parenthsis after module name?? i.e Package::Module(); and Package::Module;
Explain grooving and shortening of arrays and splicing of arrays?
Mention the difference between die and exit in Perl?
How to read a file into a hash array?