What is the difference between $array[1] and @array[1]?



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

Post New Answer

More CGI Perl Interview Questions

Explain the difference between my and local?

2 Answers  


Explain '->' in perl?

0 Answers  


What does next statement do in perl?

0 Answers  


What is perl I used for?

0 Answers  


Explain which feature of PERL provides code reusability?

0 Answers  






Comment on the scope of variables in perl.

0 Answers  


How to compare two strings in perl?

0 Answers  


What do the symbols $ @ and % mean when prefixing a variable?

1 Answers   Barclays,


What are the various uses of perl?

0 Answers  


Explain chop?

0 Answers  


Explain ivalue in perl?

0 Answers  


You want to download the contents of a url with perl. How would you do that?

0 Answers  


Categories